Hi there, I am pretty new to those things, so I couldn't figure out how to solve this, and if it is actually that easy. just found that awk could help:(.
so i have a textfile with strings and numbers (originally copy pasted from word, therefore some empty cells) in the following structure:
There are 6 such strings in total that should each define the first line of a new textfile, and the textfile should have that name.
so for example for SC, I would like a textfile SC.txt, with content:
3 5 6
5 6 7
7 6 2
the 6 textfiles shouldn't contain weird empty spaces anymore, since another program will read them and i want to make sure this won't cause trouble.
(ah, the number of lines is always 6, except for the last string, if that helps).
I am ideally looking for an easy solution in bash or python which i can understand. my files are not big...
My awk solution writes blank lines to the file <empty><empty><empty>.txt. Once luja defines how fields are separated then we can make the proper adjustments.
uh, hexdump, ok i did that (in the terminal just typed that followed by the file name, yes?!) it gave me something really not similar to the file but ok, if that helps:
---------- Post updated at 06:31 PM ---------- Previous update was at 06:21 PM ----------
i just realised that actually the empty fields do not matter. when i used awk '{print $1}' i got the first column whether there was an empty space at the beginning of the line or not. so i basically just got the first entry in each line. so i guess that makes the solution easier. it should just write the numbers, so colums 2-4 if there is the string in front and then continue with colums 1-3 until the next string. does that make sense?
so that worked.
the resulting textfiles still show an empty space before lies 2 to 6 (not in line 1 because there was the string). i don't understand enough about the way those textfiles are encoded, i.e. what they actually contain or not. but maybe i should remove those in the resulting files to make sure. so i got rid of these with:
awk '{$1=$1}1' SP.txt > SP2.txt
. maybe that could be combined with the first awk command? but else i just put it in sequentially, actually i could do that first i guess...