I have a service supplier that sends us data on a disk (at least for now) in a csv format. Here is an example of that data:
"N","MYWAY","6439116","16"
,"11179563
0359191309
","N","11.
7","N","12
.0","Prepa
id","20030
325172959"
,"N",,,"N"
,,,,"N",,"
N",,,,,,,,
,,,,,,,,,,
,,,"N",,"1
79563","4.
86","4.86"
,"0.00","1
",,"JONES & CO","JANET","269 SOUTH 20TH STREET",,,"United States","55555","MYTOWN","
PA",,,,,,"
N","N","4.
86","Packa
ge","11.7"
,"22279563
0359191309
","None","
63324-1001
",,,,,"N",
,"N",,,,,,
"N",,,"N",
,"N","N",,
,,,,,,,,,,
,,,,,,,,"N
",,,,"0","
0","0",
"N","MYWAY","6439116","16"
,"33379563
0359742713
","N","1.0
","N","1.0
","Prepaid
","2003032
5172959","
N",,,"N",,
,,"N",,"N"
,,,,,,,,,,
,,,,,,,,,,
,"N",,"179
563","4.54
","4.54","
0.00","1",
,"CHUCK SMITH",,"2301 N MY ST",,,"United States","44444","MYTOWN","
PA",,,,,,"
Y","N","4.
54","Packa
ge","1.0",
"1Z1795630
359742713"
,"None","4
0415-2055-
2403",,,,,
"N",,"N",,
,,,,"N",,,
"N",,"N","
N",,"Y",,"
email","CH
UCK SMITH",,,"ME@YAHOO.COM","N
",,,,,,,,,
,,"N",,,,"
0","0","0"
,
What I would like to do with this data is to read it from the disk and write it to a SQL table. I have the following code to get the file from the user's machine.
<form name="frm_UPLOAD" action="ACTION_LOAD_DAILY_
INFO.cfm" enctype="multipart/form-da
ta" method="post">
<input name="filename" size="40" type="file"><br>
<input type="Submit" value="Upload">
</form>
Then here is where I get stuck...this is my action page.
<cfoutput>
<cfset #loop_count# = 1>
<cffile ACTION="READ" FILE="#form.filename#" VARIABLE="DISK_DATA">
<cfloop Index="LOOP_COUNTER" list="#DISK_DATA#" delimiters=""",""">
This is where I would insert
</cfloop>
</cfoutput>
I'm having trouble with the null values and determining where the record ends because it isn't fixed width. Also, the null values aren't being counted in the loop so counting characters doesn't seem to work.
Perhaps I'm doing it all wrong...I guess I'm just looking to see if there is a simple CF solution. Example code would be very beneficial.
Thanks!