Read in csv headers, allow client to choose what goes where
Posted: Mon Jan 19, 2009 11:00 am
I am working on a program to read in a csv file and modify it to fit certain criteria. I am new to php, so I am not very good at making the visible interface. How can I dynamically read in the headers from a csv file - lets say 45 columns and allow a client to assign them to about 25 columns in the final output file? Of course, only 25 of the original 45 columns will even be used, the others will be ignored. The file to be modified will also be labeled differently from the labels we want to use.
For example, I want to read in a txt file with the 25 headers we want to use and display them on the screen along with the column number. Such as:
First Name - 1, Last Name - 2, Address - 3, ZIP - 4, Email - 5..... Tel - 25
Next, I read in the csv file headers from the data we want to format and display them as such with an input box next to each:
tel# 1 [], fax# 2 [], zipcode 3 [], email 4 [], residence 5 []..... firstname 45 []
Then I want the client to be able to point out which of the 45 items goes where by entering the appropriate number next to each. But the 25 final headers can each only be used one time.
I know how to read in the txt file and display it on the screen. But I do not know how to read in the CSV file dynamically and assign it to the proper places as needed using a form.
I can read in a csv file line by line and assign it through programming to each appropriate header manually, but that is very time consuming and I have to write a new file for each and every spreadsheet I read in. Literally every spreadsheet is different than the last. And I am dealing with hundreds because we are taking in data from many sources. I just cant figure out how to do this dynamically.
Any help would be greatly appreciated.
For example, I want to read in a txt file with the 25 headers we want to use and display them on the screen along with the column number. Such as:
First Name - 1, Last Name - 2, Address - 3, ZIP - 4, Email - 5..... Tel - 25
Next, I read in the csv file headers from the data we want to format and display them as such with an input box next to each:
tel# 1 [], fax# 2 [], zipcode 3 [], email 4 [], residence 5 []..... firstname 45 []
Then I want the client to be able to point out which of the 45 items goes where by entering the appropriate number next to each. But the 25 final headers can each only be used one time.
I know how to read in the txt file and display it on the screen. But I do not know how to read in the CSV file dynamically and assign it to the proper places as needed using a form.
I can read in a csv file line by line and assign it through programming to each appropriate header manually, but that is very time consuming and I have to write a new file for each and every spreadsheet I read in. Literally every spreadsheet is different than the last. And I am dealing with hundreds because we are taking in data from many sources. I just cant figure out how to do this dynamically.
Any help would be greatly appreciated.