Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

Need Batch File for CSV file

Original Message
Name: osbm
Date: March 7, 2008 at 10:19:41 Pacific
Subject: Need Batch File for CSV file
OS: Windows XP Pro
CPU/Ram: 2.00 Ghz, 1.87 GB RAM
Model/Manufacturer: ver 2002 sp2
Comment:
I need a batch file that will:

1. add the prefix: http ://www.onlinesuperbargainmall.com/goto.html?url=
to the first column

2. delete everything before and including the first ">" symbol in the 4th column and delete the </q> in the same column.

3. change 100&w=100 to 300&w=300 in the 4th column

4. delete the 6th column (price)

5. delete "Home > " from the 7th column then separate that same column where the next " > " appears into two columns: category and subcategory

6. change the "yes" in the "best selling column" to "<i mg sr c="http ://www.onlinesuperbargainmall.com/firepits/wp-content/themes/ColdBlue/images/bestseller.gif" align="left" height="43" hspace="10" vspace="5" width="45" />" and delete all the no's

7. then change the titles from

product url product id product name product description image url category Best Selling

to


link productid title description image category subcategory custom1

You can find a before and after csv file here: http://www.knowlescorp.com/batchfil...

I will pay $10 paypal if anyone can help me.
I am running Windows XP pro version 2002 sp2.

If you could also supply me with the command to run the batch file
(yeah I do need help)

Thanks.


Report Offensive Message For Removal


Response Number 1
Name: BlueMan
Date: March 7, 2008 at 15:28:11 Pacific
Subject: Need Batch File for CSV file
Reply: (edit)
Hi,

I don't know how to do this in a batch file, but I think it can easily be done in a C file that reads the CSV file -- which I believe is a text file -- and modifies it as required. Very easy in C. You then simply run the C executable by clicking on an Icon on your desktop assigned to it the same way you would execute the batch file.

The job might take a couple of hours by anyone less than a professional, maybe faster if done by a professional.


Report Offensive Follow Up For Removal

Response Number 2
Name: ghostdog
Date: March 7, 2008 at 22:27:54 Pacific
Subject: Need Batch File for CSV file
Reply: (edit)
there are many tools out there that does this kind of job that involves parsing files and manipulating string, better than batch's capabilities. Perl/Python/awk/sed etc even Java if you know it. There's certainly no need to use C for that.
If you can download and install gawk from here:http://gnuwin32.sourceforge.net/packages/gawk.htm.
then here's one solution.

[code]
BEGIN{
OFS=FS=","
s=" s=s"wp-content/themes/ColdBlue/images/bestseller.gif\" align=\"left\""
s=s" height=\"43\" hspace=\"10\" vspace=\"5\" width=\"45\" />"
print "link,productid,title,description,image,category,subcategory,custom1"
}
NR>1{ $1="http://www.onlinesuperbargainmall.com/torches/goto.html?url="$1
gsub(/"<q cite=.*"""">|<\/q>"/,"",$4 )
gsub(/100\&w=100/,"300\\&w=300",$5)
n=split($7,a,">")
gsub(/ +/,"",a[2]);gsub(/ +/,"",a[3])
$6=a[2]
$7=a[3]
}
$8 ~ /yes/ { $8=s }
$8 ~ /no/ { $8="no deleted" }
{print}

[/code]
save the above as somefilename.awk and from the command line :

c:> gawk -f somefilename.awk yourcsvfile > newfile


Report Offensive Follow Up For Removal

Response Number 3
Name: osbm
Date: March 8, 2008 at 00:59:27 Pacific
Subject: Need Batch File for CSV file
Reply: (edit)
Since this is all completely foreign to me I didn't really know what to download. I downloaded http://gnuwin32.sourceforge.net/dow...

I don't know if it is what i needed but that is what i downloaded. I installed the program to C:\Program Files\GnuWin32

I then saved the program file as tool.awk opened up cmd and went to c:> and typed as you posted but I got this error: 'gawk' is not recognized as an internal or external command, operable program or batch file.

Where do I go from here?


Report Offensive Follow Up For Removal

Response Number 4
Name: ghostdog
Date: March 8, 2008 at 02:18:45 Pacific
Subject: Need Batch File for CSV file
Reply: (edit)
you can edit your PATH variable to include c:\program files\gnuwin32 ( where your gawk.exe is ) or you can just copy gawk.exe into c:\windows\system32 directory.
make sure you saved tool.awk into c:\ or some other directory you created, for example, c:\test..
then from the command line
c:\test> gawk -f tool.awk yourfile
also make sure your input file is in c:\test too..that's about it.
to save to another file, use the > output redirection symbol

Report Offensive Follow Up For Removal

Response Number 5
Name: osbm
Date: March 8, 2008 at 05:03:23 Pacific
Subject: Need Batch File for CSV file
Reply: (edit)
ah, I assumed all the above, however, I cannot find a gawk.exe in the install directory. Which file do I download from here: http://sourceforge.net/project/show...

I guess I need to find the executable file. But I can't find it.


Report Offensive Follow Up For Removal


Response Number 6
Name: ghostdog
Date: March 8, 2008 at 05:45:57 Pacific
Subject: Need Batch File for CSV file
Reply: (edit)
its here http://gnuwin32.sourceforge.net/pac...
look under download, and download the binary http://gnuwin32.sourceforge.net/dow... (Install it and you will see a "bin" directory in c:\program files\gnuwin2. gawk.exe is inside this "bin" directory. move it to your system32 and you can use it anywhere in your script. this part is quite easy and you should be able to do it without much guidance

Report Offensive Follow Up For Removal

Response Number 7
Name: osbm
Date: March 8, 2008 at 06:43:19 Pacific
Subject: Need Batch File for CSV file
Reply: (edit)
well i am not sure how to install it but i unzipped it and found the gawk.exe file and moved it to c:\ folder and ran the command.

gawk -f tool.awk before.csv > after.csv

it then said:
gawk: tool.awk:1: [code]
gawk: tool.awk:1: ^syntax error

I uploaded my tool.awk file here: http://www.knowlescorp.com/tool.zip

Thanks.


Report Offensive Follow Up For Removal

Response Number 8
Name: ghostdog
Date: March 8, 2008 at 09:39:27 Pacific
Subject: Need Batch File for CSV file
Reply: (edit)
dude, remove the [code] and [/code].

Report Offensive Follow Up For Removal

Response Number 9
Name: osbm
Date: March 8, 2008 at 16:24:40 Pacific
Subject: Need Batch File for CSV file
Reply: (edit)
done. now i am getting this:

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Joshua>cd\

C:\>gawk -f tool.awk before.csv > after.csv
gawk: tool.awk:3: s="
s=s"wp-content/themes/ColdBlue/images/bestseller.gif\" align=\"left\""
gawk: tool.awk:3: ^ syntax error
gawk: tool.awk:3: s="
s=s"wp-content/themes/ColdBlue/images/bestseller.gif\" align=\"left\""
gawk: tool.awk:3: ^ syntax error
gawk: tool.awk:3: s="
s=s"wp-content/themes/ColdBlue/images/bestseller.gif\" align=\"left\""
gawk: tool.awk:3:
^ syntax error
gawk: tool.awk:3: s="
s=s"wp-content/themes/ColdBlue/images/bestseller.gif\" align=\"left\""
gawk: tool.awk:3:
^ backslash not last charact
er on line

C:\>

Any ideas?


Report Offensive Follow Up For Removal

Response Number 10
Name: ghostdog
Date: March 8, 2008 at 19:18:34 Pacific
Subject: Need Batch File for CSV file
Reply: (edit)
i have no problem with it. pls give it a try again. here's mine. http://www.mediafire.com/?nydebdxeuxp

Report Offensive Follow Up For Removal

Response Number 11
Name: osbm
Date: March 9, 2008 at 04:32:13 Pacific
Subject: Need Batch File for CSV file
Reply: (edit)
ok. Now I am starting to get excited. I got it to work with your test.awk file. Just a few things:

Compare the two files. correct.csv errors.csv http://www.knowlescorp.com/needfixe...

1) In the second row, errors.csv is outputting:
product url product id product name product description image url price category Best Selling

2) The <q cite=.*""""> and </q> is not being removed from the description column

3) in the custom1 column it is showing "no deleted"

Thanks!


Report Offensive Follow Up For Removal

Response Number 12
Name: ghostdog
Date: March 9, 2008 at 07:26:36 Pacific
Subject: Need Batch File for CSV file
Reply: (edit)
2) <q cite=.*""""> is removed at my side. <q cite=.*""""> will match exactly 4 double quotes. If you input data does not contain that 4 "s then it will not get deleted.
3) i show "no deleted" just for example. You just substitute whatever you want to get displayed if that column contains "no".

here's the amended code
please try to meddle with it yourself

http://www.mediafire.com/?vclam9gddb0


Report Offensive Follow Up For Removal

Response Number 13
Name: osbm
Date: March 9, 2008 at 08:51:27 Pacific
Subject: Need Batch File for CSV file
Reply: (edit)
For some reason this line seems to be ignored:
gsub(/"<q cite=.*"+>|<\/q>"/,"",$4 )
because it is still included in the output.

Everything else is great.
Thanks for the help.


Report Offensive Follow Up For Removal

Response Number 14
Name: ghostdog
Date: March 9, 2008 at 19:23:56 Pacific
Subject: Need Batch File for CSV file
Reply: (edit)
not sure. everything works fine for me as you can see from my example output. if you want, provide your before.csv and your test.awk file.there may be some differences in your before.csv file compare with mine.

Report Offensive Follow Up For Removal

Response Number 15
Name: osbm
Date: March 9, 2008 at 22:21:27 Pacific
Subject: Need Batch File for CSV file
Reply: (edit)
http://www.knowlescorp.com/almost.zip

Report Offensive Follow Up For Removal

Response Number 16
Name: ghostdog
Date: March 9, 2008 at 23:09:08 Pacific
Subject: Need Batch File for CSV file
Reply: (edit)
http://www.mediafire.com/?nijzyj90xaj

Report Offensive Follow Up For Removal

Response Number 17
Name: osbm
Date: March 9, 2008 at 23:28:36 Pacific
Subject: Need Batch File for CSV file
Reply: (edit)
Yo ghostdog your the man. ROTFL about "dude, remove the [code] and [/code]." Obviously I haven't a clue. Much Thanks! You really saved me tons of time. Paypal?

Report Offensive Follow Up For Removal

Response Number 18
Name: ghostdog
Date: March 9, 2008 at 23:32:45 Pacific
Subject: Need Batch File for CSV file
Reply: (edit)
no need. just remember my name.

Report Offensive Follow Up For Removal

Response Number 19
Name: osbm
Date: March 14, 2008 at 11:15:32 Pacific
Subject: Need Batch File for CSV file
Reply: (edit)
After I run test.awk on my datafeed file, it combines any 2 or 3 words that make up the category and subcategory into 1 word (it takes out the space(s). I have attached my test.awk and my before.csv and after.csv file. http://www.knowlescorp.com/help.zip

Is there any way to automatically convert encoding found in the csv file like &# 39; &n bsp; &# 174; and whatever else so it reads correctly without any code? Its only happens in the title and description field.

Thanks.


Report Offensive Follow Up For Removal

Response Number 20
Name: ghostdog
Date: March 14, 2008 at 20:49:49 Pacific
Subject: Need Batch File for CSV file
Reply: (edit)
http://www.mediafire.com/?3zsfint1d2l

Report Offensive Follow Up For Removal

Response Number 21
Name: osbm
Date: March 16, 2008 at 11:51:28 Pacific
Subject: Need Batch File for CSV file
Reply: (edit)
I am trying to replace all instances of: " with "

I thought this would work: gsub(""",""",$4) but it does not. Any ideas?


Report Offensive Follow Up For Removal

Response Number 22
Name: osbm
Date: March 16, 2008 at 11:54:26 Pacific
Subject: Need Batch File for CSV file
Reply: (edit)
I am trying to replace all instances of: &q uot; with "

I thought this would work: gsub("&q uot;",""",$4) but it does not. Any ideas?


Report Offensive Follow Up For Removal

Response Number 23
Name: ghostdog
Date: March 19, 2008 at 06:30:07 Pacific
Subject: Need Batch File for CSV file
Reply: (edit)
try escaping it

gsub(""","\"",$4) or
gsub(""","\042",$4)

and why do you have a space between "q" and "u"


Report Offensive Follow Up For Removal

Response Number 24
Name: osbm
Date: March 21, 2008 at 11:50:45 Pacific
Subject: Need Batch File for CSV file
Reply: (edit)
because if i didn't put the space in, it would have printed in this post as the symbols. wrapping it in [code][/code] doesn't matter. thats why i had to re-post.

I'll try "escaping it" (don't really know what that means but I will plugin the code you gave me) thanks!


Report Offensive Follow Up For Removal

Response Number 25
Name: osbm
Date: March 21, 2008 at 18:26:39 Pacific
Subject: Need Batch File for CSV file
Reply: (edit)
I keep getting an error:

C:\Documents and Settings\Joshua\Desktop\affiliate blog\websites>gawk -f test.aw
k datafeed.csv > datafeed1.csv
gawk: test.awk:27: gsub(""","\"",$4)
gawk: test.awk:27: ^ backslash not last character on line

C:\Documents and Settings\Joshua\Desktop\affiliate blog\websites>gawk -f test.aw
k datafeed.csv > datafeed1.csv
gawk: test.awk:29: gsub(""","\042",$4)
gawk: test.awk:29: ^ backslash not last character on line

C:\Documents and Settings\Joshua\Desktop\affiliate blog\websites>

here's my test.awk file http://www.knowlescorp.com/test.zip

Thanks again.


Report Offensive Follow Up For Removal

Response Number 26
Name: ghostdog
Date: March 23, 2008 at 06:10:34 Pacific
Subject: Need Batch File for CSV file
Reply: (edit)
the word & q u o t; (without spaces) is missing as i posted the solution. You should really put in these words, and not """ in

gsub(""","\"",$4)


Report Offensive Follow Up For Removal



Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Need Batch File for CSV file

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




how to setup call of duty to joytok

WindowsME / HotMail Problem

Corrupt memory

Convert fat32 to Ntfs

Best WinMo phone of 2008


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC