Treat it as two lists. The first using Chr(13) or Chr(10) as
a delimiter, the second using ,:
The only problem you'll get with that is if the CSV contains a record
like the following (which is perfectly valid):
1,Banana,Long and yellow, with a slight bend
As CF list functions would see it,
On Mon, 10 Jan 2005 20:06:12 -0600, Aaron Rouse [EMAIL PROTECTED] wrote:
And if using Oracle you could use SQLLDR. I have the need to do this
just with CF and been using a CFC I got off this list for uploading it
but still have not found the time to really progress with it.
On Mon, 10 Jan
2) Use the awesome Ostermiller utilities at
http://ostermiller.org/utils/CSV.html to actually parse the
CSV file
Hmm, excellent resource. One to bookmark I think! Cheers Dave.
Tim.
--
---
Badpen Tech - CF and web-tech:
CSVs are much trickier than a lot of people realize to handle in my
experience. For example, there are two separate CSV formats -- one the
world uses and one Microsoft uses.
Actually, there is no standard for CSV. There are just about as many
formats as there are implementations. Consequently,
Ken wrote:
Hi. I want to enable the user to upload a csv file, then the data
should be validated against pre-defined criteria for different columns
in the csv file. Once that is done, I want to write the validated
rows from the csv file to the DB.
I would change the process a bit. Don't
The carriage return within a cell is actually the problem I ran into
and never looked back at what I will do to work past it. This
requirement is kind of low on my list of things to get done so just
keeps moving towards the back burner. The data I have is populated
into an Excel spreadsheet and
On Tue, 11 Jan 2005 11:11:27 -0500, Ben Rogers [EMAIL PROTECTED] wrote:
CSVs are much trickier than a lot of people realize to handle in my
experience. For example, there are two separate CSV formats -- one the
world uses and one Microsoft uses.
Actually, there is no standard for CSV.
Which further emphasizes my point that basic ColdFusion solutions of
looking for carriage returns and the like is not a robust way to solve
this problem.
I wasn't debating that point. However, it's worth noting that this is
entirely dependent on the application which generated the CSV file. If
On Tue, 11 Jan 2005 12:35:56 -0500, Ben Rogers [EMAIL PROTECTED] wrote:
Which further emphasizes my point that basic ColdFusion solutions of
looking for carriage returns and the like is not a robust way to solve
this problem.
I wasn't debating that point. However, it's worth noting that
Agreed. For the record, it looks like Excell (I'm using 2003) does
indeed allow carriage returns. I just ran a quick test (when in the
cell, hit Alt+Enter to start a new line within it) and it saved out
with the carriage return.
Good to know. Thanks for testing.
That wasn't my point at all.
I was just providing a method using carriage returns and lists,
not the entire code. It's fairly simple to find out if the data
delimiters are correctly interpreted, or embedded in the data
since the list lengths (fields) will be wrong. Those that don't match
the field count can be saved to
Hi. I want to enable the user to upload a csv file, then the data
should be validated against pre-defined criteria for different columns
in the csv file. Once that is done, I want to write the validated
rows from the csv file to the DB.
Please help.
Thanks,
Ken
Treat it as two lists. The first using Chr(13) or Chr(10) as
a delimiter, the second using ,:
cfset CSV = CSVFileData
cfloop index=idx List=#CSV# delimiters=#chr(13)#
cfset Firstcolumn = ListGetAt(idx,1)
cfset SecondColumn = ListGetAt(idx,2)
Continue for all columns and validate
Insert into
If you're using SQL Server, you can create a DTS package then call it
from CF. I couldn't believe the difference in speed when I switched
to DTS. (If you need to use CF to validate the incoming data, use DTS
to populate a temp table, CF to pull it out and insert the validated
data into its
And if using Oracle you could use SQLLDR. I have the need to do this
just with CF and been using a CFC I got off this list for uploading it
but still have not found the time to really progress with it.
On Mon, 10 Jan 2005 16:53:15 -0700, Paul Malan [EMAIL PROTECTED] wrote:
If you're using SQL
15 matches
Mail list logo