Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 11th, 2005, 8:01 AM   #1
rasha
Newbie
 
Join Date: May 2005
Posts: 2
Rep Power: 0 rasha is on a distinguished road
help needed urgently

I have file with 42 columns separated by |
Some lines start with number and some with "" and have "" in every field except in the last two columns (fields).
I would like to replace all fields containing "" in the lines not starting with numbers with the values in the corresponding fields in the closesd preceiding line starting with number except last two fields.

Here is the example of the file, but it will probably be badly wraped here due to the fact that lines are quite long.

1|" ALUMINIOS LA BLANCA S.L. (EN LIQUIDACION)"|" ALUMINIOS LA BLANCA S.L. (EN LIQUIDACION)"|"PG INDUSTRIAL ALDAYTURRIAGA"|"01400"|""|"AMURRIO"|0|"¡lava"|"SPAIN"|"+34 945/393428"|""|""|"B01190313"|0|"Sociedad limitada"|"11/2/1995"|"12/31/2002"|"Unquoted Company"|""|""|""|""|""|""|""|"FABRICACION Y VENTA DE VENTANAS, MAMPARAS, SEPARADORES, CIERRES, PUERTAS."|"2812"|"12/31/2002"|"U1"|"Unconsolidated Accounts"|"Uncons."|"Dissolution"|"7/9/2003"|618|""|""|"EUR"|0|1.000000000|580|"RODRIGUEZ GOMEZ CLEMENTE"|"Liquidator"
2|" CONSTRUCCIONES COBESAN 2000 S.L."|" CONSTRUCCIONES COBESAN 2000 S.L."|"GR RESIDENCIAL PALMERAS, 7"|"21720"|""|"ROCIANA DEL CONDADO"|0|"Huelva"|"SPAIN"|"+34 959/416156"|""|""|"B21308432"|0|"Sociedad limitada"|"12/11/2000"|"12/31/2002"|"Unquoted Company"|""|""|""|""|""|""|132|"CONSTRUCCION EN GENERAL, PROMOCION, COMPRAVENTA DE BIENES INMUEBLES"|"4521"|"12/31/2002"|"U1"|"Unconsolidated Accounts"|"Uncons."|"Active"|""|3946|""|"BENAVENTE BUENO MANUEL"|"EUR"|0|1.000000000|580|"BENAVENTE BUENO MANUEL"|"Member of the Board"
""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|"SANCHEZ GARCIA AMPARO"|"Member of the Board"
3|"0 A 24 MULTISERVICIO SOCIEDAD LIMITADA."|"0 A 24 MULTISERVICIO SOCIEDAD LIMITADA."|"CL PERIODISTA TEODORO LLORENTE, 4"|"46009"|""|"VALENCIA"|0|"Valencia"|"SPAIN"|"+34 96/3296309"|""|""|"B96918560"|0|"Sociedad limitada"|"10/22/1999"|"12/31/2002"|"Unquoted Company"|""|""|""|""|""|""|4|"LA PRESTACION DE LOS SERVICIOS DE CARPINTERIA, CERRAJERIA, FONTANERIA Y ELECTRICIDAD."|"4542"|"12/31/2002"|"U1"|"Unconsolidated Accounts"|"Uncons."|"Active"|""|504|""|"MOLINA AGUILAR JOSE LUIS"|"EUR"|0|1.000000000|580|"MOLINA AGUILAR JOSE LUIS"|"Sole Administrator"
4|"0 KM EXPRESS S.L."|"0 KM EXPRESS S.L."|"AV DE FUENTEMAR, 29"|"28820"|""|"COSLADA"|0|"Madrid"|"SPAIN"|"+34 91/6741111"|"+34 91/6739262"|""|"B81687428"|0|"Sociedad limitada"|"3/14/1997"|"12/31/2002"|"Unquoted Company"|""|""|""|""|""|""|33|"TRANSPORTE AEREO, MARITIMO Y TERRESTRE DE TODA CLASE DE MERCANCIAS A NIVEL NACIONAL E INTERNACIONAL."|"6340"|"12/31/2002"|"U1"|"Unconsolidated Accounts"|"Uncons."|"Active"|""|10637|"VILLANUEVA RODRIGUEZ URBANO JOSE"|"ALBINANA GONZALEZ FRANCISCO JAVIER"|"EUR"|0|1.000000000|580|"VILLANUEVA RODRIGUEZ URBANO JOSE"|"President of the Board"
""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|"ALBINANA GONZALEZ FRANCISCO JAVIER"|"Executive Director"
""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|""|"STOCCO SERGIO"|"Administrator"
rasha is offline   Reply With Quote
Old May 11th, 2005, 11:07 AM   #2
rasha
Newbie
 
Join Date: May 2005
Posts: 2
Rep Power: 0 rasha is on a distinguished road
I have manged to solve the problem with following program

I have managed to solve the problem
awk -F"|" '{if ($2 !~"\"\"" )  {print $0; X=$1 "|" $2 "|" $3 "|" $4 "|" $5 "|" $6 "|" $7 "|" $8 "|" $9 "|" $10 "|" $11 "|" $12 "|" $13 "|" $14 "|" $15 "|" $16 "|" $17 "|" $18 "|" $19 "|" $20 "|" $21 "|" $22 "|" $23 "|" $24 "|" $25 "|" $26 "|" $27 "|" $28 "|" $29 "|" $30 "|" $31 "|" $32 "|" $33 "|" $34 "|" $35 "|" $36 "|" $37 "|" $38 "|" $39 "|" $40 "|" $41 } else {print X "|" $42 "|" $43}}' inputfile.txt > outputfile.txt

Last edited by rasha; May 11th, 2005 at 11:14 AM.
rasha is offline   Reply With Quote
Old May 16th, 2005, 9:39 AM   #3
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,436
Rep Power: 7 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
congrats
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:26 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC