|
-
May 28th, 2002, 03:15 PM
#1
Thread Starter
Addicted Member
Reading Null characters from a text file....
Hey gang,
Well as I usually do before I post anything, I've searched the forums and can't seem to find what I need. I'm having a problem reading in a string from a CSV file that contains null characters. When I view the line of text in notepad it looks how I need it to look, like:
but when I read the file in:
InRecItem is eqaul to:
I need those positions defined in the read because my program needs to tell how many spaces are between each comma. I can't change the input file format so that isn't even an option. Is there a way I can replace the null characters w/ spaces on the read? Is there any other way I can read the file besides "Line Input" that would help me out?
Any help is appreciated......Thanks
If you can think it....you can code it....
-
May 28th, 2002, 03:22 PM
#2
Not NoteMe
Try this, not too sure what the Line bit does, as the code below reads a text file line by line, which i think is what you're doing.
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts. 
-
May 28th, 2002, 03:30 PM
#3
Thread Starter
Addicted Member
Hey SLH,
Yes, I've tried "Input #1" and that didn't work either. The difference between Input and Input Line is that Input will automatically delimit the data for you on the read. So it will give me first "4005", then "" and so on......in effect doing the same as Line Input only one field at a time.
One other thing to note, I don't know if I'm using the term "null" correctly, but when I view that line of text in a HEX editor:
"4005, ,"
looks like
34 30 30 35 2C 00 00 2C
as you can see, the "spaces" are a byte value of zero. Or as us COBOL programs like to call... LOW-VALUES
Still stuck.....
If you can think it....you can code it....
-
May 28th, 2002, 03:53 PM
#4
PowerPoster
you say:
when I view that line of text in a HEX editor:
"4005, ,"
looks like
34 30 30 35 2C 00 00 2C
this implies that your input file is NOT a csv file at all but is in fact a binary file and will have to be read as such. A CSV file is by definition a text files (aka a "flat" file) and such files do NOT under any circumstance include binary zeros. If you read a binary file as though it were a text file, you can count on getting this kind of error.
-
May 28th, 2002, 04:11 PM
#5
Thread Starter
Addicted Member
Well, as far as I know, a CSV by definition is a Comma Separated Values file and can be anything delimited by commas. It can be flat or variable and contain whatever data you want. I work in data processing and have seen them contain every character there is. I've just never attempted to read them in though VB before now. I know what you mean though, most CSV's are "text" files that can be seen face value in any kind of text editor. But regardless what you call it, I'm still having the problem wether I read it as Binary or not. My current attempt is to read it char by char, although that's not looking too promising at the moment.
If you can think it....you can code it....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|