parsing CSV files question
Posted: Fri Jul 03, 2009 4:08 pm
Hello,
So i am working on a project for a company where i am taking a (large) CSV file exported from another program, and parsing this data into nice, easy to read graphical data - relatively simple idea.
Here is the problem:
The data in the CSV file contains dollar amounts, and dollar amounts of greater then $999 is in the format: 1,234.00. You might be able to see the problem.
So when i explode the data in the file on commas i get the following (for example):
[1026] => "11
[1027] => 541.00"
the original amount stored in the file was: "11,541.00"
so the explode is splitting this into 2 parts.. but i need just the 1 value.
I tries using preg_replace to only replace commas in between quotes with nothing, but this was just creating a huge mess.
If anyone has any suggestions about how i could better parse this, PLEASE enlighten me!
Thanks,
kris
So i am working on a project for a company where i am taking a (large) CSV file exported from another program, and parsing this data into nice, easy to read graphical data - relatively simple idea.
Here is the problem:
The data in the CSV file contains dollar amounts, and dollar amounts of greater then $999 is in the format: 1,234.00. You might be able to see the problem.
So when i explode the data in the file on commas i get the following (for example):
[1026] => "11
[1027] => 541.00"
the original amount stored in the file was: "11,541.00"
so the explode is splitting this into 2 parts.. but i need just the 1 value.
I tries using preg_replace to only replace commas in between quotes with nothing, but this was just creating a huge mess.
If anyone has any suggestions about how i could better parse this, PLEASE enlighten me!
Thanks,
kris