Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 8th, 2004, 10:01 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 249
Thanks: 0
Thanked 0 Times in 0 Posts
Default Parse Txt File with Reg Expression

I am just looking for some advice here about ASP regular expressions and if this could be done with them or any better ideas about how to handle this. We have some text files, that I will have the user upload to the server, these files are comma delimited, they need to be converted to tab delimited and we need to delete the quotes. We cannot use the replace function because of the fields would have comma within the quotes and we want to leave those alone such as this field ,"ELAN POLO, INC.", Below are a few rows of the text file, each file will contain about 107,000 lines to process.


4717836,912,1,1,201,5042,"ELAN POLO, INC.","M0225","M0225","EA R2000 CONV",54.99,29.97
13861155,912,1,1,201,5042,"ELAN POLO, INC.","M0345","M0345","EA WARNING TRACK MID",39.99,19.97
3809583,912,1,1,201,5042,"ELAN POLO, INC.","M0462","","EA SMOKE LO",29.99,24.99
3809606,912,1,1,201,5042,"ELAN POLO, INC.","M0462","","EA SMOKE LO",29.99,24.99

Thanks
Mike
__________________
Peace
Mike
http://www.eclecticpixel.com
 
Old June 8th, 2004, 01:35 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hello,

Yeah, you could use Regular Expression to do this. Comma-separated files are always trickly, because quite commonly in the data you often see a comma.

Is this data coming from another source? If so, if you can change the source, what you can do is update the source to use the "^" character. Then:

replace all commas with tabs (vbTab)
replace all " with nothing
replace all ^ with ,

Something like that. I know it may be unlikely that you can do this; I thought I would just throw it out there.

Brian
 
Old June 9th, 2004, 12:42 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Mike,

If that is tough, then you can try this.

As always, there is a SPACE after COMMA in the string "ELAN POLO, INC.", you can

First replace that ", " with something like "!/@/*/~"
Then replace the other COMMA's blindly to "^" as Brian said
Then replace character you did in the 1st step back to ", "

This should help.
Cheers!

_________________________
-Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
read any ".txt" file RodrigoGuteriez C# 3 November 18th, 2008 01:07 PM
REG EXPRESSION pallone Javascript How-To 4 August 28th, 2008 09:37 AM
parse a csv file shinny Pro Java 4 September 11th, 2006 06:26 AM
export to .txt file meimy Pro VB.NET 2002/2003 0 May 31st, 2004 02:24 AM
Wrox URL reg. expression richard.york Forum and Wrox.com Feedback 0 May 20th, 2004 12:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.