|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
How do I add a comma to qualify a column?
Hello,
I'm working with a ColdFusion scheduled task that takes a .CSV file with 13 columns and parses through the information and inserts it into a holding table, etc... The problem I'm having is the file has the first 12 columns populated with data, but the 13th column is blank. This is ok, however there isn't a comma to qualify the 13th column. How do I do a list find function and insert a column in position 13 if one doesn't exist? This is an example of how the data currently is with the header following by the data being passed: Company,Username,Password,FirstName,LastName,Email,SupervisorEmail,Position/Title,Region,Status,LAC_Code,ShiftDescShort,CorePath 00000,test1,__whitespace__,Test,Test,test@dummy1.com,test@dummy1.com,SSE,NNN,1,AAA;IIR;CT,Day M-F I would like to right a statement to add a comma if one doesn't exist after the 12th column in the list like below. 00000,test1,__whitespace__,Test,Test,test@dummy1.com,test@dummy1.com,SSE,NNN,1,AAA;IIR;CT,Day M-F, This is the code to loop over the file: <cfloop list="#filecontent#" index="ThisUser" delimiters="#Chr(13)##CHR(10)#"> Any suggestions? |
|
#2
|
|||
|
|||
|
I recommend placing some kind of temp variable in that position. Use a regular expression to replace any instances of ',,' or ',end of line' with something like ',~,' or ',~end of line' and then you'll know that any list elements with ~ are empty.
Another option is that, if you know there are 13 columns, parse each line and do a ListLen(), and if the length is less than 13, flag it as needing an extra element at element 13.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > How do I add a comma to qualify a column? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|