Reputation: 10823
I've this issue: I've a CSV file that contains some data in this format:
100,30,1.704,,7
101,,suka,,5
and I should import this CSV inside mysql table
As you can seen, this csv has empty fields, denoted by double commas ',,' . I want using sed and regular expression, define pattern ,, and if it's matched substituing it with number 58 inside my csv file . Anyone can help me, I don't knwo regex very well.
Upvotes: 1
Views: 215
Reputation: 31
You may try using notepad++ if you want regex options. Open Search and replace set the search mode as "Regular Expressions" replace ,,
with ,58
. I just tried it and it works... ,,,,,,,,
to ,58,58,58,58
Upvotes: -1
Reputation: 31284
something like this should do the trick:
sed -e 's/,,/,58,/g'
which will search ('s') or ',,' and replace it by ',58,' for all occurences ('g'; as opposed to only the first occurence))
Upvotes: 1