0

We've got a tab delimited text file that needs to be sent to a customer in pipe delimited format with all hidden characters scrubbed. They suggest manual switching the delimiter in windows language setting, then opening in word pad to search for characters. I feel this is a silly waste of time that most likely can be solved with VB or batch.

hard returns, $, and a few other random characters specific to this client need to be removed before it's sent

Any guidance would be very much appreciated!

example data (just a tab delimited txt file)

Item number Artist last name    Artist first name   Title   Image width Image height    Paper width Paper height    Retail price    Small Text Descriptive  Category    Format  UPC
Community
  • 1
  • 1
Jimmy
  • 15
  • 3
  • What do you mean by data feed? – David Ruhmann Jun 26 '13 at 20:18
  • please explain: input format example, "hidden characters". – Endoro Jun 26 '13 at 20:31
  • it's essentially just an inventory listing with product descriptions, sku's, weight, available quantities etc... – Jimmy Jun 26 '13 at 21:05
  • @Jimmy this is unreadable in the comment box. Please edit your question with the new information. – Endoro Jun 26 '13 at 21:45
  • formatting on the above may be botched a bit here, but it's literally just a tab delimited text file that needs scrubbed of certain characters (hard returns, $, etc...) – Jimmy Jun 26 '13 at 22:24
  • sorry @endoro i'm not entirely certain how to keep the tabbed formatting from getting lost in the example. – Jimmy Jun 26 '13 at 22:31
  • @DavidRuhmann we're trying to use batch files to send data instead of EDI – Jimmy Jun 26 '13 at 22:35
  • "hard returns", its not easy to fix that in batch without exact knowledge of the structure. If not here, so post the data at eg. pastebin. – Endoro Jun 26 '13 at 22:47
  • @endoro Example data at http://pastebin.com/TYRV21rT – Jimmy Jun 26 '13 at 22:57
  • can you only use batch, or also other tools? eg. GNUwin32. – Endoro Jun 26 '13 at 23:04
  • You state *"hard returns, $, and a few other random characters specific to this client need to be removed before it's sent"*, but you are not specific. And your example does not have any of those characters. I'm not sure how you expect people to help you. But see [How can you find and replace text in a file using the Windows command-line environment?](http://stackoverflow.com/q/60034/1012053) for a number of options. My favorite is [REPL.BAT - a hybrid JScript/batch regex search and replace utility](http://stackoverflow.com/a/16735079/1012053) that I wrote. – dbenham Jun 26 '13 at 23:44
  • Have you tried Notepad++? – Excel Developers Jun 27 '13 at 10:07

1 Answers1

0

This uses the free GnuSED and converts TAB to | while removing $ Z Y and X (case sensitive):

@echo off
sed -e "s/\t/|/g" -e "s/\$//g" -e "s/Z//g" -e "s/Y//g" -e "s/X//g" file.txt >filenew.txt

This extra batch script removes end of line characters but some OS versions will remove leading whitespace.

@echo off
sed -e "s/\t/|/g" -e "s/\$//g" -e "s/Z//g" -e "s/Y//g" -e "s/X//g" file.txt >tmp.tmp
for /f "delims=" %%a in (tmp.tmp) do >>filenew.txt set /p "=%%a"<nul
del tmp.tmp
foxidrive
  • 40,353
  • 10
  • 53
  • 68
  • Thanks @foxidrive this definitely works to convert to tab and remove the specified characters...but doesn't address carriage returns. I've found some other questions that address this using coreutils tr command but the results are still coming up blank. i'd wager it's my lack of understanding the syntax. – Jimmy Jun 27 '13 at 15:48