I have many files that need to be altered in order to import into cpanel, mysql. The number pattern is layout out like ,2|5|7|31|37|43|5
To import the file into the correct field, the data needs to be in format of 02050731374305
Is it better to just use notepad++ and edit all the files or is there a better way to import this data? Mysql field only allows numeric and is limited to 14 digits on this particular file.
The files I have are pretty much alike but vary in length. There are only 2 columns total in the file to import into mysql, cpanel.
reg expression might work but I have been finding errors on the replacement as it is picking up other numbers in the row and changing the data.
3
Answers
Here’s a quick solution using
awk
:as I a said a fucntion, that breaks the string and build the new one, will help you
So you can
And get
This can easily be done with Notepad++, using the power of lookaround.
This will add a zero before each digit alone and it works for any number of values:
(?<!d)(?=d(?!d))
0
Explanation:
Screenshot (before):
Screenshot (after):