06-11-2013 10:08 AM
Hi,
Urgent help/direction required to do the following.
I have 6 serial numbers and one text file, attached (for example xs0000_G1_7.6V_pre.log).
In the text file there are 48 column, each column is 4 hex digits long. In the file attached the first 8 columns have data.
I need to make 6 new files, <S/N>.txt, containing 8 columns of data, with the last file containing the last 8 columns and the first <S/N>.txt having the first 8 columns of data.
What do you think?
Thanks
Simon
06-11-2013 01:25 PM
I suppose you'll have to tokenize the lines (strtok) as they are read, i'd put each column piece in an array, then send those pieces to the file pointers.
Look at
FILE *fileHandle;
fileHandle=fopen(filename,"w+");
..
for(...){
fprintf(fileHandle,"formatted msg, %s\n",columnArray[i]);
}
...
statusReturned=fclose(fileHandle);
06-12-2013 12:36 AM
Since data in the file are fixed-lenght, you could:
Open the source file
Open 8 destination files
Do:
Read a line
Loop this 8 times:
Read 40 characters (8 data 4 characters long + 1 space)
move to a destination file
End-of-loop
Until end-of-source-file
Close destination files
Close source file
06-12-2013 09:01 AM - edited 06-12-2013 09:04 AM
Hi,
Thanks for the help and direction.
Attached is how I got around it, I am sure it could be cleaned up, if I knew how, but this works so it is a good base to continue as there will be a lot of differentI/P files to be handled.
Thanks
Simon