0
         CLASS RECORD OF THE STUDENT FROM THE PREVIOUS BATCH WHO TOPPED
Name (Roll no) #    Location   Section     Rank (MARKS)     Gender   
Anna (+)            USA        A1          First (100)      Female
(04)                California V
ADDITIONAL RECORDS OF THE STUDENTS FROM THE PREVIOUS BATCH NEXT IN LIST
Name (Roll no) #    Location   Section     Rank (MARKS)     Gender
Bob (-)             USA        A2          First (99)       Male
(07)                Florida    VI
Eva (+)             USA        A4          Second (96)      Female
(12)                Ohio       V           English (99)
                                           Maths(100)
Other records are not available currently.Some records may be present which can be given on request.

Getting the text file from a PDF using pdftotext. Using below AWK command I am getting the above data.
Table data is unevenly space separated. Remove the lines which is the whole line is in Uppercase

pdftotext -layout INPUTFILE.pdf INPUTFILE.txt
awk '/RESULTS/{flag=1;next}/OTHER DATA/{flag=0}flag' INPUTFILE.txt | column -ts $'\t' -n


How do I get the table data in tab delimited format(Below Format)?
Code in a generic way, so it works other types of tables also.

Name (Roll no) #    Location    Section     Rank (MARKS)    Gender  
Anna (+)            USA         A1          First (100)     Female
(04)                California  V
Bob (-)             USA         A2          First (99)      Male
(07)                Florida     VI
Eva (+)             USA         A4          Second (96)     Female
(12)                Ohio        V           English (99)
                                            Maths (100)
3
  • Your desired format is not a tab-delimited table, between "(04)" and "California" I bet there are more tabs than between the first two header strings. Plus, you're already using 'column -t', so I don't understand what's being asked exactly.
    – seshoumara
    Commented Mar 18, 2018 at 18:28
  • There is only spaces in the whole table no TABS at all even between "(04)" and "California",. 'column -t' is not properly formatting the table. I want to make this table content in TAB DELIMITED format.
    – bioinform
    Commented Mar 19, 2018 at 6:42
  • Is the 1st column the entire string "Name (Roll no) #" and the 4th "Rank (MARKS)"? Also, in "Maths(100)" there is no space in between, but after column -t there is one now?? Did you add it yourself?
    – seshoumara
    Commented Mar 19, 2018 at 7:19

1 Answer 1

0

Let me know if this is what you're looking for

$ awk '{if ($1 in a) next; a[$1]=$0; print}' <filePath> | grep -v  -e STUDENT  -e Other | column -ts $'\t' 
Name (Roll no) #    Location   Section     Rank (MARKS)     Gender   
Anna (+)            USA        A1          First (100)      Female
(04)                California V
Bob (-)             USA        A2          First (99)       Male
(07)                Florida    VI
Eva (+)             USA        A4          Second (96)      Female
(12)                Ohio       V           English (99)
                                           Maths(100)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .