I had a question about altering a text file. I have data in the following format.
1 a,b,c 2 d,e 3 a, l, m,n
Note that some of them have spaces after the coma
Now I have to resort the data in the following format
1 a 1 b 1 c 2 d 2 e 3 a 3 l 3 m 3 n
Now my plan is to first parse the data, and hold a count of how many data elements there are for each number. (Ex. for the number 1, there are 3 elements). Then I would move down the data by 3 spaces, starting from the bottom. Kinda like moving an array. (The main concern here is space more than time complexity)
Then I would enter each data element at the top.
My first question is, how exactly would I parse the data in a txt file and indicate delimiters such as the coma and the possible spaces.
Second, having done this, how would I just move down a whole line inside a text file down one?
I am very sorry if my question is convoluted. I will gladly clarify anything. Thank you so much for your time! Please let me know if there is anything i need to add. Also, I'm comfortable in both java and c. So advice on either language is useful.