0

Not looking for someone to provide a full script (unless someone wants to be kind enough to do so) looking to figure our or get some direction (after searching on the internet and not finding answers) as to how to search an excel CSV file for special characters (or any specified characters) and removing them leaving the remaining text in the field only.

Example: Say a field has abc*123. I would like to remove the * leaving abc 123.

Not sure how this would be done if someone could share a path to finding how to do this I am willing to do the scripting and learning to make it work ... just very unfamiliar and unsure where to start

looking to do this with batch scripting as that is the scripting I am most familiar with currently

tried using this

for /f "delims==" %%A in (customer.csv) do set string=%%A & echo !string:*= ! >> output.csv

but that removed the entire field of each not leaving the rest?
Please let me know what I may be missing.

greybeard
  • 2,249
  • 8
  • 30
  • 66
Midnite
  • 1
  • 3
  • I'd suggest you might be better off looking at doing this with Powershell rather than batch, since you get far more control and it properly understands working with csv content natively. For instance see https://stackoverflow.com/questions/45963765/replace-string-in-an-imported-csv-file – Keith Langmead May 02 '23 at 05:00
  • Yes - `*` is going to be a problem as `:*string` means `everything up to and including string`. I'd suggest you try `sed` or `(g)awk` - freeware (but verify your download with a virus-checker, of course) – Magoo May 02 '23 at 06:40
  • I will look into sed and gawk but was hoping there is a way to do this with BAT scripting ? – Midnite May 02 '23 at 06:42
  • (The example result looks *replacing* special/specified characters rather than *removing*.) – greybeard May 03 '23 at 09:14
  • well replacing it with a blank space is the only way I found it to work properly ... unless someone else can share a different solution ? Idea ? – Midnite May 04 '23 at 02:27

0 Answers0