Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Pipe Delimited to Tab Delimted Conversion


PupStar

Recommended Posts

Posted

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

 

Posted

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

Posted

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

Posted

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).

Posted

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

Posted

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.

Posted

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

Posted

@@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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...