PupStar Posted January 9, 2016 Posted January 9, 2016 Hi Guys, Trying to reduce work and automate some tasks, does anyone know of any php scripts that can convert a pipe delimited file to a tab delimted file? Thanks Mark
♥bruyndoncx Posted January 9, 2016 Posted January 9, 2016 you sure you can't change the delimeter in the processing script ? KEEP CALM AND CARRY ON I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support). So if you are still here ? What are you waiting for ?! Find the most frequent unique errors to fix: grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt
PupStar Posted January 9, 2016 Author Posted January 9, 2016 you sure you can't change the delimeter in the processing script ? I am not currently using a script just wondering if there is anything out there thats worth using
MrPhil Posted January 9, 2016 Posted January 9, 2016 Most scripts and commands for processing CSV style files give you an option or flag to change the delimiter. That would certainly be the easiest method. If you're using something that's brain-dead, or you first need to merge a pipe-delimited file with a tab-delimited one, I'm sure something could be done. On a Linux system, you might be able to use "sed" (stream editor), although it wouldn't know how to deal with pipes within fields (e.g., fields surrounded by " or the pipe is escaped with \ ). The "awk" utility might also work (it is based on splitting up lines into fields), but could have problems with pipes within fields. Both these utilities, built in to standard Linux (but possibly removed from a server), are available for Windows. Worst case, if you have the delimiter used within fields, would be to write a custom script to handle this (such as in Perl).
PupStar Posted January 9, 2016 Author Posted January 9, 2016 Most scripts and commands for processing CSV style files give you an option or flag to change the delimiter. That would certainly be the easiest method. If you're using something that's brain-dead, or you first need to merge a pipe-delimited file with a tab-delimited one, I'm sure something could be done. On a Linux system, you might be able to use "sed" (stream editor), although it wouldn't know how to deal with pipes within fields (e.g., fields surrounded by " or the pipe is escaped with \ ). The "awk" utility might also work (it is based on splitting up lines into fields), but could have problems with pipes within fields. Both these utilities, built in to standard Linux (but possibly removed from a server), are available for Windows. Worst case, if you have the delimiter used within fields, would be to write a custom script to handle this (such as in Perl). Cheers Phil, I have been using excel but on a few thousand lines I was just wondering if I could automate the task with a one click type thing. No matter its not that important, just thought I would ask about
MrPhil Posted January 9, 2016 Posted January 9, 2016 If you're using Excel to import or export this CSV file, I would think it would let you set the delimiter used. You might want to do some Googling if you haven't done so already.
Dan Cole Posted January 10, 2016 Posted January 10, 2016 @@PupStar Can you use a simple search and replace in your favorite editor? Dan Need help? See this thread and provide the information requested. Is your version of osC up to date? You'll find the latest osC community version (CE Phoenix) here.
PupStar Posted January 10, 2016 Author Posted January 10, 2016 If you're using Excel to import or export this CSV file, I would think it would let you set the delimiter used. You might want to do some Googling if you haven't done so already. @@MrPhil This is what I am currently doing
PupStar Posted January 10, 2016 Author Posted January 10, 2016 @@PupStar Can you use a simple search and replace in your favorite editor? Dan @@Dan Cole I would but with over 5000 lines and about 20 columns it would take a while ;)
MrPhil Posted January 10, 2016 Posted January 10, 2016 @@Dan Cole I would but with over 5000 lines and about 20 columns it would take a while ;) In ViM, editing your pipe-delimited CSV file, :g/|/s/|/\t/g . All done. With sed, you should be able to do something very similar (one command global search and replace). In either case, any | within a field (not intended to be a separator) would have to be manually fixed up.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.