I am writing a little utility to convert data. I want to be able to use it on different formats. I have most of the code written to handle different fields (date and time formats etc).
The thing that is giving me a little trouble is the first step, PARSEing out the various fields in a string:
hFile = FREEFILE
OPEN FilePathStr+FileNameStr FOR INPUT AS hFile LEN = 32768
INPUT #hFile, InputStr ' Read a line of Data
DateStr = PARSE$(InputStr, any ", ", 1)
TimeStr = PARSE$(InputStr, any ", ", 2)
Now this works for comma delimited fields like:
19900118, 1610, 340.7
or
19900118,1610,340.7
But I often get data with just spaces delimiting it:
19900118 1610 340.7
or
19900118 1610 340.7
or
19900118 1610 340.7
PARSEing on the space will only work if there is 1 space between each field. that is not allways the case
So how do you PARSE out the fields without getting into a cumbersome loop and checking each character for a space etc etc
Do you wizards have a neat little trick?
------------------
Kind Regards
Mike
The thing that is giving me a little trouble is the first step, PARSEing out the various fields in a string:
hFile = FREEFILE
OPEN FilePathStr+FileNameStr FOR INPUT AS hFile LEN = 32768
INPUT #hFile, InputStr ' Read a line of Data
DateStr = PARSE$(InputStr, any ", ", 1)
TimeStr = PARSE$(InputStr, any ", ", 2)
Now this works for comma delimited fields like:
19900118, 1610, 340.7
or
19900118,1610,340.7
But I often get data with just spaces delimiting it:
19900118 1610 340.7
or
19900118 1610 340.7
or
19900118 1610 340.7
PARSEing on the space will only work if there is 1 space between each field. that is not allways the case
So how do you PARSE out the fields without getting into a cumbersome loop and checking each character for a space etc etc
Do you wizards have a neat little trick?
------------------
Kind Regards
Mike
Comment