Re: How to parse a text file...
>> 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: > > > As pre-parsing the file already, you might as well keep it all in CF. However, you could also skip the header in your LOAD DATA statement using IGNORE x LINES; http://dev.mysql.com/doc/refman/5.0/en/load-data.html ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312811 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: How to parse a text file...
> 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: -Justin Scott, http://www.tlson.com/ ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312807 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: How to parse a text file...
Well, I've tried loops and inner loops, etc, but nothing is giving me the results I need. 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... Any more clues, anyone? Rick > -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... > >file= > "e:\inetpub\webroot\real_estate_data\hmls\data\2008_0918_idx_custom\active_photos.txt" > variable= "active_photos" /> > > "#chr(10)&chr(13)##chr(10)&chr(13)#", "", "All")#> > >file= > "e:\inetpub\webroot\real_estate_data\hmls\data\2008_0918_idx_custom\active_photos_edited.txt" > output = "#active_photos#" /> > > That just gave me a file with the text, "active_photos", and a return symbol > after it... > > Thoughts? > > Rick ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312806 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: How to parse a text file...
> "#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 the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312801 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: How to parse a text file...
> 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 ;-) ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312800 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: How to parse a text file...
Suggestions on how to replace the sequential newlines? I tried this... 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 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 newlines with a single newline and > such. > > cheers, > barneyb > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312799 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: How to parse a text file...
>>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 description in each element, then as you loop on that array, in each iteration use list functions to separate the file name and the description. ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312798 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: How to parse a text file...
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 *really* weak at (sadly). as far as the cf part is concerned: you can use two loops for that. one to loop over the list of elements divided by line breaks (13/10), one inner loop that uses chr#9 as delimiter. bye, marcus Rick Faircloth schrieb: > 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... > > -- Mit freundlichen Grüßen, Marcus Raphelt at.net websolutions Mühlenbeck & Raphelt GbR Klever Str. 60 47839 Krefeld Tel.: 02151 / 3699732 Fax : 02151 / 3699734 Mob.: 0151 / 58113803 mailto: [EMAIL PROTECTED] http://www.atnet-websolutions.de ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312795 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
RE: How to parse a text file...
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 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 newlines with a single newline and > such. > > cheers, > barneyb > > On Thu, Sep 18, 2008 at 2:00 PM, Rick Faircloth > <[EMAIL PROTECTED]> wrote: > > 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, > > then a return...chr(10)&chr(13)...at the end of each pair. > > > > 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, but so far it's not working. > > > > I read the file with this code: > > > > > file = "e:\active_photos.txt" > > variable = "active_photos" /> > > > > From here, I've tried listtoarray, etc., but I can't get the > > info in the text file into an array properly. > > > > I can use listtoarray with chr(10)&chr(13) as the delimiters, > > but that gives me each row as an element. > > > > I can't figure out how to use both delimiters to parse the rows and the row > > elements. > > > > I was using the MySQL function, "load data infile," to load the data into a > > table, > > but some of the text files have blank lines, like the key was > > struck a couple > > of times, and that throws an error with load data infile. > > > > Suggestions? > > > > Thanks, > > > > Rick > > > -- > Barney Boisvert > [EMAIL PROTECTED] > http://www.barneyb.com/ > > ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312793 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: How to parse a text file...
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 newlines with a single newline and such. cheers, barneyb On Thu, Sep 18, 2008 at 2:00 PM, Rick Faircloth <[EMAIL PROTECTED]> wrote: > 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, > then a return...chr(10)&chr(13)...at the end of each pair. > > 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, but so far it's not working. > > I read the file with this code: > >file = "e:\active_photos.txt" > variable = "active_photos" /> > > From here, I've tried listtoarray, etc., but I can't get the > info in the text file into an array properly. > > I can use listtoarray with chr(10)&chr(13) as the delimiters, > but that gives me each row as an element. > > I can't figure out how to use both delimiters to parse the rows and the row > elements. > > I was using the MySQL function, "load data infile," to load the data into a > table, > but some of the text files have blank lines, like the key was struck > a couple > of times, and that throws an error with load data infile. > > Suggestions? > > Thanks, > > Rick -- Barney Boisvert [EMAIL PROTECTED] http://www.barneyb.com/ ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312791 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
How to parse a text file...
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, then a return...chr(10)&chr(13)...at the end of each pair. 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, but so far it's not working. I read the file with this code: >From here, I've tried listtoarray, etc., but I can't get the info in the text file into an array properly. I can use listtoarray with chr(10)&chr(13) as the delimiters, but that gives me each row as an element. I can't figure out how to use both delimiters to parse the rows and the row elements. I was using the MySQL function, "load data infile," to load the data into a table, but some of the text files have blank lines, like the key was struck a couple of times, and that throws an error with load data infile. Suggestions? Thanks, Rick ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:312789 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4