Need some help replacing letters in a set of scripts

Forum rules
Before you post please read how to get help

Need some help replacing letters in a set of scripts

Postby Mir on Sat Jun 14, 2014 1:22 am

I'm making a cross-platform spreadsheet that uses a lot of concatenation. Due to a bug in a version of Excel commonly found on Windows XP (which a lot of people still use), I need to use the ampersand (&) symbol instead of =concatenate(A5:91). As you can guess, I just copy and paste it over and over again to save time. I also use Replace All in Leafpad to replace the A in A1 with B, and I need to get all the way up to the column CI. This will take a while even with Replace all, so I'm wondering if someone can write a script which will take the following:

Code: Select all
=$data.J4&$data.J5&$data.J6&$data.J7&$data.J8&$data.J9&$data.J10&$data.J11&$data.J12&$data.J13&$data.J14&$data.J15&$data.J16&$data.J17&$data.J18&$data.J19&$data.J20&$data.J21&$data.J22&$data.J23&$data.J24&$data.J25&$data.J26&$data.J27&$data.J28&$data.J29&$data.J30&$data.J31&$data.J32&$data.J33&$data.J34&$data.J35&$data.J36&$data.J37&$data.J38&$data.J39&$data.J40&$data.J41&$data.J42&$data.J43&$data.J44&$data.J45&$data.J46&$data.J47&$data.J48&$data.J49&$data.J50&$data.J51&$data.J52&$data.J53&$data.J54&$data.J55&$data.J56&$data.J57&$data.J58&$data.J59&$data.J60&$data.J61&$data.J62&$data.J63&$data.J64&$data.J65&$data.J66&$data.J67&$data.J68&$data.J69&$data.J70&$data.J71&$data.J72&$data.J73&$data.J74&$data.J75&$data.J76&$data.J77&$data.J78&$data.J79&$data.J80&$data.J81&$data.J82&$data.J83&$data.J84&$data.J85&$data.J86&$data.J87&$data.J88&$data.J89&$data.J90&$data.J91


Replace the "J" with "K", and then copy that to a new line below the original text:

Code: Select all
=$data.J4&$data.J5&$data.J6&$data.J7&$data.J8&$data.J9&$data.J10&$data.J11&$data.J12&$data.J13&$data.J14&$data.J15&$data.J16&$data.J17&$data.J18&$data.J19&$data.J20&$data.J21&$data.J22&$data.J23&$data.J24&$data.J25&$data.J26&$data.J27&$data.J28&$data.J29&$data.J30&$data.J31&$data.J32&$data.J33&$data.J34&$data.J35&$data.J36&$data.J37&$data.J38&$data.J39&$data.J40&$data.J41&$data.J42&$data.J43&$data.J44&$data.J45&$data.J46&$data.J47&$data.J48&$data.J49&$data.J50&$data.J51&$data.J52&$data.J53&$data.J54&$data.J55&$data.J56&$data.J57&$data.J58&$data.J59&$data.J60&$data.J61&$data.J62&$data.J63&$data.J64&$data.J65&$data.J66&$data.J67&$data.J68&$data.J69&$data.J70&$data.J71&$data.J72&$data.J73&$data.J74&$data.J75&$data.J76&$data.J77&$data.J78&$data.J79&$data.J80&$data.J81&$data.J82&$data.J83&$data.J84&$data.J85&$data.J86&$data.J87&$data.J88&$data.J89&$data.J90&$data.J91

=$data.K4&$data.K5&$data.K6&$data.K7&$data.K8&$data.K9&$data.K10&$data.K11&$data.K12&$data.K13&$data.K14&$data.K15&$data.K16&$data.K17&$data.K18&$data.K19&$data.K20&$data.K21&$data.K22&$data.K23&$data.K24&$data.K25&$data.K26&$data.K27&$data.K28&$data.K29&$data.K30&$data.K31&$data.K32&$data.K33&$data.K34&$data.K35&$data.K36&$data.K37&$data.K38&$data.K39&$data.K40&$data.K41&$data.K42&$data.K43&$data.K44&$data.K45&$data.K46&$data.K47&$data.K48&$data.K49&$data.K50&$data.K51&$data.K52&$data.K53&$data.K54&$data.K55&$data.K56&$data.K57&$data.K58&$data.K59&$data.K60&$data.K61&$data.K62&$data.K63&$data.K64&$data.K65&$data.K66&$data.K67&$data.K68&$data.K69&$data.K70&$data.K71&$data.K72&$data.K73&$data.K74&$data.K75&$data.K76&$data.K77&$data.K78&$data.K79&$data.K80&$data.K81&$data.K82&$data.K83&$data.K84&$data.K85&$data.K86&$data.K87&$data.K88&$data.K89&$data.K90&$data.K91


And then move on to the next sequential letter in the alphabet. Once it gets to Z, it needs to start over with AA. Then it needs to move on to AB, AC, AD, until it reaches AZ. Then it should replace the AZ with BB, and so on until it reaches CI. (Note that this is the letter "c" and the letter "i", but uppercase).
Mir
Level 1
Level 1
 
Posts: 8
Joined: Sat Apr 12, 2014 8:58 pm

Linux Mint is funded by ads and donations.
 

Re: Need some help replacing letters in a set of scripts

Postby WharfRat on Sun Jun 15, 2014 1:15 am

This is what I tried

Code: Select all
cat testline|while read l;do echo "$l" >> newline;sed 's/J/K/g' <<< "$l" >> newline;done


The data I used from your post in testline - I used two lines.
http://pastebin.com/iBdC9wm2


The results in newline
http://pastebin.com/7ykxW2Gh

Good luck :wink:
Image
User avatar
WharfRat
Level 13
Level 13
 
Posts: 4551
Joined: Thu Apr 07, 2011 8:15 pm


Return to Scripts & Bash

Who is online

Users browsing this forum: No registered users and 3 guests