I have a csv file that I am parsing, formatting and then writting to a new
file. I am currently using an array, but I have some lines that might
contain more data than others. I know for sure that columns 0-33 will
always be there, but the customer has the option to add another set of
columns to the row if needed. I do know that the addition's will always
be 18 columns and I do know that they can add up to 15 set's of 18. So,
the row length could be 0-33 or 0-51 if they add one additional set or 303
columns if they go up to 15.
The tricky part is I have to format each column for the new file that is
created, I do this using sprintf. I have so far tried to use array_slice
for the first 18 columns, then I do another array_slice starting at 18
and using the column count to get the last column in the row. Here is the
code:
array_slice($fields, 18,$lineCount);
foreach ($fields as $key => $value){
print "$key|$value\r\n";
}
The format of the new file will be this:
01-Customer information
02-Other information
03a Required Info (that can repeat up to 15 times per line)
03b ""
04b ""
04-Close Customer Record
Repeat cycle for each row. The inner loop happens between the 02 and 04
records. Remember, I need to format each individual column, they are
different format options.
If you have some thoughts, I would be all ears as I have been starring at
this too long and too hard.
Thanks,
-Scott
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php