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
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.
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.
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.
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
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.
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
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
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.
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?
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.
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!
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>
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