Parse excel file with html on each cell


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Parse excel file with html on each cell
# 1  
Old 08-14-2014
Parse excel file with html on each cell

Quote:
Hello all i was wondering how can achieve the next result, i used sed
Code:
sed 's/<[^>]*>//g' file > newfile

to remove html tags but i would like to create columns like shown below, can you help how to do it
HTML Code:
<DIV><P>Pré-condição aceder ao ecrã Home do MRS.</P></DIV><DIV><P>OK.</P></DIV><DIV><P>Seleccionar Pesquisa de Recepção Directa.</P></DIV><DIV><P>Confirmar que abriu ecrã de Recepção Directa.</P></DIV><DIV>

Quote:
It would have to stay this way in excel
Column 1
Pré-condição aceder ao ecrã Home do MRS.
Seleccionar Pesquisa de Recepção Directa.

Column 2
OK.
Confirmar que abriu ecrã de Recepção Directa.
# 2  
Old 08-14-2014
I don't see any columns in the output below?

Your input doesn't look like an Excel file, what is it?
# 3  
Old 08-20-2014
Dear Corona688,

Thank you for you're reply...

This is an extraction from Microsoft MTM...the extraction is made to a excel file and in one of the cells it comes this:

HTML Code:
<DIV><P>Pré-condição aceder ao ecrã Home do MRS.</P></DIV><DIV><P>OK.</P></DIV><DIV><P>Seleccionar Pesquisa de Recepção Directa.</P></DIV><DIV><P>Confirmar que abriu ecrã de Recepção Directa.</P></DIV><DIV>
Is was wondering how could I turn it into this....
Column A1(excel)
Code:
Pré-condição aceder ao ecrã Home do MRS.

column B1(excel)
Code:
 OK.

Column A2(excel)
Code:
Seleccionar Pesquisa de Recepção Directa.

column B2(excel)
Code:
Confirmar que abriu ecrã de Recepção Directa.

Best regards,
Rui Oliveira

Last edited by rbatte1; 08-20-2014 at 08:52 AM.. Reason: Added CODE tags, capitalised first person singular and spellings
# 4  
Old 08-20-2014
You can't generate a Excel format file very easily, however you could build a delimited file. The most common is Comma Separated Values file and on Windows associated with a .csv extension that Excel will read in. The format of the file is that each record is a row and each column is separated by a comma, like this:-
Code:
Cell A1,Cell B1,Cell C1,Cell D1
Cell A2,Cell B2,Cell C2,Cell D2
Cell A3,Cell B3,Cell C3,Cell D3
etc.

If you can work out how to split your input, you can build output records to suit.
  • What have you tried so far?
  • What output/errors do you get?
  • What OS and version are you using?
  • What are your preferred tools? (C, shell, perl, awk, etc.)
  • What logical process have you considered? (to help steer us to follow what you are trying to achieve)
Most importantly, What have you tried so far?

There are probably many ways to achieve most tasks, so giving us an idea of your style and thoughts will help us guide you to an answer most suitable to you so you can adjust it to suit your needs in future.


We're all here to learn and getting the relevant information will help us all.



Robin
# 5  
Old 08-20-2014
Hello Robin, thanks for you're quick reply

Well I haven't tried much yet because I was struggling to find the best way to do it... I simply used
Code:
sed 's/<[^>]*>//g' file > newfile

to remove the tags but I was trying to see if it is real hard to make the way I told in the answer above....

I'll try to achieve what you told me to...this is my best answer!Smilie

Last edited by rbatte1; 08-20-2014 at 08:51 AM.. Reason: Capitalised first person singular and spellings
# 6  
Old 08-20-2014
So, what do you have in newfile? I've just got the tags stripped out, but now no way to split it up, unless the full stops are consistent and can be used.

Is it always going to be more that the original input will be like:-
HTML Code:
<DIV><P>Cell A1.</P></DIV><DIV><P>Cell B1.</P></DIV><DIV><P>Cell A2.</P></DIV><DIV><P>Cell B2.</P></DIV><DIV><P>Cell A3.</P></DIV><DIV><P>Cell B3.</P></DIV><DIV><P>Cell A4.</P></DIV><DIV><P>Cell B4.</P></DIV>
If that is certain, then maybe we're better working from that.



Robin
# 7  
Old 08-20-2014
Yes there are always stops in each sentence....


newfile give me something like this...

Quote:
Pré-condição aceder ao ecrã Home do MRS.OK.Seleccionar Pesquisa de Recepção Directa.Confirmar que abriu ecrã de Recepção Directa, e que por definição abre na SECTION Direta.Validar SECTION Alertas.Alertas é composta por (Checkbox's Alertas e Relatórios de Artigos por: "Reservas", "Folhetos Ruturas", "Campanhas Folhetos futuros", "Promo Futura", "Novas" e "Rupturas").
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cell color based on Status in HTML output

Hi, I need to get the Status Column in Green if it is approved and Red if it is declined in the HTML output attachment#!/bin/bash body_csv="/authlistener/ProdA/service/queryRS.csv" body_html="/authlistener/ProdA/service/queryRS.html" ... (1 Reply)
Discussion started by: maddelav
1 Replies

2. Shell Programming and Scripting

awk to parse html file

Is it possible in awk to parse a webpage (EDAR Gene Sequencing - Genetic Testing Company | The DNA Diagnostic Experts | GeneDx), the source code is attached. <title> EDAR Gene Sequencing <dt>Test Code:</dt> <dd>156 </dd> <dt>Turnaround Time:</dt> <dd>6-8 weeks </dd> ... (4 Replies)
Discussion started by: cmccabe
4 Replies

3. UNIX for Advanced & Expert Users

awk - If then else rule like Excel cell

Hi, I need extract / transpose where "Y" in the input file My input file is Item,EB,SB,SD,TP,GR LP,Y,N,N,N,Y GC,Y,N,N,N,N CO,N,Y,Y,Y,Y PS,Y,N,N,Y,Y Expecting output is EB-/'LP/',/'GC/',/'PS/' SB-/'CO/' SD-/'CO/' TP-/'CO/',/'PS/' GR-LP,CO,PS I appreciate for your help Regards (4 Replies)
Discussion started by: myrole
4 Replies

4. Shell Programming and Scripting

Perl - Append data to existing excel cell

Hello All, I have the following code in PERL to write data to excel sheet. Can someone please help me about how to append data to an exisitng cell? For ex in the below given case,Cell 1,1 has Active State PERL Now I want to add a new line like "prorgamming" without overwritting the... (3 Replies)
Discussion started by: prasperl
3 Replies

5. Shell Programming and Scripting

need to parse the jil file into an excel file

Hi I have the following as input /* ----------------- backupJIL ----------------- */ insert_job: backupJIL job_type: c command: autorep -J ALL -q > /home/autosys/...p/autosys_jil_bk machine: machine owner: autosys@machine permission: gx,ge,wx,we date_conditions: 1 days_of_week:... (7 Replies)
Discussion started by: ramky79
7 Replies

6. UNIX for Advanced & Expert Users

shell script to parse html file

hi all, i have a html file something similar to this. <tr class="evenrow"> <td class="data">added</td><td class="data">xyz@abc.com</td> <td class="data">filename.sql</td><td class="modifications-data">08/25/2009 07:58:40</td><td class="data">Added TK prof script</td> </tr> <tr... (1 Reply)
Discussion started by: sais
1 Replies

7. Shell Programming and Scripting

Export into a single cell of excel sheet...

The awk is giving below output: SELECT divrel.child_org_idn org_main_idn NULL ( VARCHAR(200)) div_nam_2 NULL ( VARCHAR(200)) div_nam_3 NULL ( VARCHAR(200)) div_nam_4 NULL ( VARCHAR(200)) div_nam_5 NULL ( VARCHAR(200)) div_nam_6 NULL ( VARCHAR(200)) div_nam_7 ... (2 Replies)
Discussion started by: goutam_igate
2 Replies

8. Shell Programming and Scripting

PERL: Modify Excel cell formatting

Hi, I would like to modify an existing excel cell format to a custom format. Is there a way to do it with out writing into a new excel file. In-place editing? Thanks (0 Replies)
Discussion started by: sandeep78
0 Replies

9. Shell Programming and Scripting

How to change cell background in excel sheet using perl

I need to change a cell in an excel sheet to different background color using perl.I tried SaveParse, but was unable to get it Please help regarding this. Thanks and Regards, Neelam G https://www.unix.com/images/misc/progress.gif (0 Replies)
Discussion started by: gujrathinr
0 Replies

10. UNIX for Dummies Questions & Answers

Change the cell background in excel sheet using Perl

I need to change a cell in an excel sheet to different background color using perl. Please help regarding this. Thanks and Regards, Neelam G (1 Reply)
Discussion started by: gujrathinr
1 Replies
Login or Register to Ask a Question