473,807 Members | 2,853 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

read text file with stange format

I have a text file that is formatted like this:

123456789 SOLD 1
12/12/2006 Smith 45,525
987654321 SOLD 3
01/01/2006 Jones 23,252
I need to read this file and parse the data and then load it into the
database. I can get the values for line one but how can I get the values for
the next line? I'm using the substring() method to get my data but when I
try and get the second line its returning me the data for the first line
Jun 15 '06 #1
3 1254
It sounds like a simple mistake in the code, like reading from the wrong
string variable, or something.

What does the code look like?
John wrote:
I have a text file that is formatted like this:

123456789 SOLD 1
12/12/2006 Smith 45,525
987654321 SOLD 3
01/01/2006 Jones 23,252
I need to read this file and parse the data and then load it into the
database. I can get the values for line one but how can I get the values for
the next line? I'm using the substring() method to get my data but when I
try and get the second line its returning me the data for the first line

Jun 15 '06 #2
the code is just reading the file line by line and getting the string value
using string.substrin g() method
the code works with all of the other files it reads and uploads, I just have
a newly formatted file that needs to be read
"Göran Andersson" <gu***@guffa.co m> wrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
It sounds like a simple mistake in the code, like reading from the wrong
string variable, or something.

What does the code look like?
John wrote:
I have a text file that is formatted like this:

123456789 SOLD 1
12/12/2006 Smith 45,525
987654321 SOLD 3
01/01/2006 Jones 23,252
I need to read this file and parse the data and then load it into the
database. I can get the values for line one but how can I get the values
for the next line? I'm using the substring() method to get my data but
when I try and get the second line its returning me the data for the
first line

Jun 15 '06 #3
The substring method can't return characters from any other string than
the one used to call the method.

John wrote:
the code is just reading the file line by line and getting the string value
using string.substrin g() method
the code works with all of the other files it reads and uploads, I just have
a newly formatted file that needs to be read
"Göran Andersson" <gu***@guffa.co m> wrote in message
news:%2******** ********@TK2MSF TNGP02.phx.gbl. ..
It sounds like a simple mistake in the code, like reading from the wrong
string variable, or something.

What does the code look like?
John wrote:
I have a text file that is formatted like this:

123456789 SOLD 1
12/12/2006 Smith 45,525
987654321 SOLD 3
01/01/2006 Jones 23,252
I need to read this file and parse the data and then load it into the
database. I can get the values for line one but how can I get the values
for the next line? I'm using the substring() method to get my data but
when I try and get the second line its returning me the data for the
first line


Jun 15 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
496
by: Ron | last post by:
I have a text file with the following format (pipe delimited) |column1=value|column2=value|column3=value|column4=value|... |column1=value|column2=value|column3=value|column4=value|... I have two questions. 1. Is this some new type of text file format and if so, what is the name of it.
10
25612
by: QQ | last post by:
I am trying to read data from Excel files I use the following codes, however, it didn't work Can anyone tell me what the format excel files have, what I should do to read it from C? Thanks a lot! #include <stdio.h>
14
9141
by: Mark Broadbent | last post by:
Does anybody know what is (factual please -not just guess) the quickest method to read data from a file? I am not interested in the format of the data (i.e. blocks, bytes, string etc) just that the IO to read the data is very quick. I am currently using a Streamreader and have found the readline method to perform slightly better than the read method (although it is nice to have the read's granuality of one byte). Is there any faster reader...
7
3135
by: Hallvard B Furuseth | last post by:
I'm trying to clean up a program which does arithmetic on text file positions, and also reads text files in binary mode. I can't easily get rid of it all, so I'm wondering which of the following assumptions are, well, least unportable. In particular, do anyone know if there are real-life systems where the text file assumptions below don't hold? For text mode FILE*s,
9
2026
by: srikanth | last post by:
i have a text file like below, test.txt file (actually my test file file is with 10000 lines but here i tested with 3 lines) 3 06.09.2006 16:37:25 3 06.09.2006 16:40:02 3 06.09.2006 16:42:31 i want to read this and output as it looks but iam getting abnormal
3
2964
by: =?Utf-8?B?ZGF2aWQ=?= | last post by:
I try to follow Steve's paper to build a database, and store a small text file into SQL Server database and retrieve it later. Only difference between my table and Steve's table is that I use NTEXT datatype for the file instead of using IMAGE datatype. I can not use SqlDataReader to read the data. I need your help, Thanks. -David (1) I have a table TestFile for testing: ID int FileName navrchar(255)
9
3016
by: =?Utf-8?B?QnJpYW4gQ29vaw==?= | last post by:
I want to open a text file and format it into a specific line and then apply color to a specific location of the text and then display it in a RichTextBox after all of this is done. I can do all of the above after the file is loaded into the RichTextBox, and I am trying to speed the process up by doing it in a temp file.
6
342
by: zl2k | last post by:
hi, there I have a appendable binary file of complex data structure named data.bin created by myself. It is written in the following format: number of Data, Data array Suppose I have following data.bin (3 Data appended to 2 Data): 2, data0, data1, 3, data0, data1, data2
4
3420
by: Keith G Hicks | last post by:
I'm trying to read a text file and alter the contents of specific lines in the file. I know how to use streamreader to read each line of a file. I'm doing that already to get the data into a database. What I need help with is on how to locate a specific line in the file, change it and then save the updated text file. Can anyone help me out or point me to a site that explains this clearly? Here's part of my code that reads the contents of...
0
9720
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9599
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10112
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9193
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7650
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6879
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4330
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3854
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.