1

I am using unoconv to convert different xlsx reports into csv. One of the reports has a merged cell like below.

Column_1   Column_2  Column_3  Column_4
C          ABC       DEF       123
           ABC       DEF       123
           ABC       DEF       123

Whenever I convert the xlsx file into csv. The merged cell which is column_1 is not filled with values like this.

Column_1,Column_2,Column_3,Column_4
C,ABC,DEF,123
,ABC,DEF,123
,ABC,DEF,123

Is there any option in unoconv to fill the merged cells with value? Or is there any possible work around with this using awk maybe?

Desired Ouput:

Column_1,Column_2,Column_3,Column_4
C,ABC,DEF,123
C,ABC,DEF,123
C,ABC,DEF,123
user2058738
  • 349
  • 1
  • 6
  • 15

1 Answers1

0

Following awk may help you on same.

awk 'FNR==1{$1=$1;print;next} !/^ +/{val=$1;$1=$1} /^ +/{$1=val OFS $1} 1' OFS=","   Input_file
RavinderSingh13
  • 130,504
  • 14
  • 57
  • 93
  • @user2058738. it worked well and fine for me, could you please check if you have control M characters in your Input_file by doing `cat -v Input_file` let me know then. – RavinderSingh13 Apr 09 '18 at 07:50
  • I've checked and my input file does not have control M – user2058738 Apr 09 '18 at 07:54
  • @user2058738, any error you are getting? or which OS are you using? please do let me know. – RavinderSingh13 Apr 09 '18 at 07:55
  • no any errors actually. its just that the blank cell is still not populated. OS is CentOS Linux release 7.3.1611 – user2058738 Apr 09 '18 at 08:02
  • @user2058738, when you are running is it not giving anything on terminal? or you are expecting output should be saved into Input_file itself, please clarify once? – RavinderSingh13 Apr 09 '18 at 08:03
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/168533/discussion-between-user2058738-and-ravindersingh13). – user2058738 Apr 09 '18 at 08:04