Hi, all...
I've got a text file that I'm trying to read with cffile that has
data structured like this:
96201_01.jpgMain View
96202_01.jpgAlternate View 01
etc...
This is a list of photos with a description of each photo.
There is a tab between the photo filename and the description,
Best bet would be to do listToArray() with newline as the delimiter,
and then loop over the array and split each item on a tab.
Though if you've already got LOAD DATA INFILE set up, why not just set
up some REReplaces to sanitize the input file before import. Do
things like replace sequential
Thanks for the suggestions!
Rick
-Original Message-
From: Barney Boisvert [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 18, 2008 5:04 PM
To: CF-Talk
Subject: Re: How to parse a text file...
Best bet would be to do listToArray() with newline as the delimiter,
and then loop
Hi Rick,
depending on how large the text file is, you might consider using the
gnu texttools (sed, awk, grep etc.) to convert the data to sql
statements and import the result natively via mysql. This is WAY faster
than parsing it via cf, as text file parsing is one of the things cf is
I've tried several methods to get this code into an array with
the filename as the first array element and the description as the
second array element
May be you don't need to go that far in creating an array.
Just create a single array the way you did it, with both the file name
and the
= #active_photos# /
That just gave me a file with the text, active_photos, and a return symbol
after it...
Thoughts?
Rick
-Original Message-
From: Barney Boisvert [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 18, 2008 5:04 PM
To: CF-Talk
Subject: Re: How to parse a text file...
Best bet
cfset active_photos = #replace(active_photos,
That just gave me a file with the text, active_photos, and a return
symbol after it...
Remove the quotes from active_photos so CF knows it is a variable to be
evaluated ;-)
cfset active_photos = #replace(active_photos,
#chr(10)chr(13)##chr(10)chr(13)#, , All)#
Also, check Barney's suggestion:
replace sequential newlines with a single newline and such.
~|
Adobe® ColdFusion® 8 software 8 is
-Original Message-
From: Rick Faircloth [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 18, 2008 5:50 PM
To: CF-Talk
Subject: RE: How to parse a text file...
Suggestions on how to replace the sequential newlines?
I tried this...
cffile action = read
I need to get rid of the column headers in the first line,
and then get rid of any linefeeds after the last piece of data.
This seemed fairly straightforward when I started...
and it should still be fairly straightforward:
cfset data = listRest(data, chr(10)) /
cfset data = trim(data) /
I need to get rid of the column headers in the first line,
and then get rid of any linefeeds after the last piece of data.
This seemed fairly straightforward when I started...
...and it should still be fairly straightforward:
cfset data = listRest(data, chr(10)) /
cfset data = trim(data) /
11 matches
Mail list logo