Script for updating a .csv file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script for updating a .csv file
# 8  
Old 08-16-2010
In log.txt I have

Code:
M:\shah_view\DIR_source\TEA\TEA_CabinSDmonitoring.c@@\main\base2ucm_source\main\1
    M:\shah_view\DIR_source\TEA\TEA_CanBusLine.c@@\main\base2ucm_source\main\1

file_list.csv looks like this:

Code:
4DE\SWL\SWLCommon\SWL_common.c\main\16

If log contains SWL_common.c then put a (*) mark in the side row of this line in the *.csv.

So now we have to take only the SWL_common.c from the .csv and compare it with log.txt,then we need to put a (*) mark.

Hope you understood my requirement.....

Now in this script we have to remove all the *.c in to one array and compare that each element of the array in log.txt
# 9  
Old 08-17-2010
please paste your csv file content atleast a sample with more one file name.

And let us know what is file that has to be looked extactly in log.txt

Your requirement was clear but we are not aware of your csv file format.
# 10  
Old 08-17-2010
As per my understanding your requirment is to pick all the files from log.txt which have .c extension and then need to compare them with file_list.csv.If this exists then store them in another file.
# 11  
Old 08-17-2010
Hello All,

My LOG.txt looks like this:

Code:
DIFFBL INT_1029_Rel6.0.0.90.2163@\DIR_PVOB STD_6.0.0.50_UCM_FOUNDATION_BL.480@\DIR_PVOB (COMPONENT TEA)
Comparing the following:
  INT_1029_Rel6.0.0.90.2163@\DIR_PVOB
  STD_6.0.0.50_UCM_FOUNDATION_BL.480@\DIR_PVOB
Differences:
<< INT_1029_Rel6.0.0.90.2163 (TEA)
>> STD_6.0.0.50_UCM_FOUNDATION_BL.480 (TEA)
  none

DIFFBL INT_1029_Rel6.0.0.90.637@\DIR_PVOB STD_6.0.0.50_UCM_FOUNDATION_BL.9777@\DIR_PVOB (COMPONENT LEAD)
Comparing the following:
  INT_1029_Rel6.0.0.90.637@\DIR_PVOB
  STD_6.0.0.50_UCM_FOUNDATION_BL.9777@\DIR_PVOB
Differences:
<< INT_1029_Rel6.0.0.90.637 (LEAD)
>> STD_6.0.0.50_UCM_FOUNDATION_BL.9777 (LEAD)
  << CQ00024238@\DIR_PVOB "deliver 600_dmb on 20100304.114150."
    M:\srath_view\DIR_source\LEAD\LEAD_se.c@@\main\base2ucm_source\pht_600_int\1
    M:\srath_view\DIR_source\LEAD\LEAD_calc.c@@\main\base2ucm_source\pht_600_int\1
  << CQ00024043@\DIR_PVOB " Std. 6.0 UCM Migration"
    M:\srath_view\DIR_source\LEAD\LEAD_se.c@@\main\base2ucm_source\pht_600_dev_dmb\1
    M:\srath_view\DIR_source\LEAD\LEAD_calc.c@@\main\base2ucm_source\pht_600_dev_dmb\1

Now the file_list.csv looks like this:

There are 3 columns in file_list.csv

1st column: contains (*) mark according to the corresponding row where the file is being changed

2nd column :contains the path of the file as well as the file name

3rd column: contains the version of the file.

Code:
Ex:
column 1                       column 2                                    column 3

  
*                 DIR_source\LEAD\LEAD_se.c                               main\1

             DIR_source\LEAD\LEADcommmon\lead_configFile.h        main\2

*                  DIR_source\LEAD\LEAD_calc.c                            main\3   
                    DIR_source\TEA\TEA_tail.c                            main\2


So As Lead_se.c and Lead_calc.c is changed while comparing two baseline,which we captured it in log.txt.
Now the script should update the 1st column by putting a (*) mark corresponding to the row and by updating the column 3 with the latest version number of the file.........


Hope you all got my point.........

The column2 may contain .c,.h,.txt,.sfg
# 12  
Old 08-17-2010
Code:
awk '{printf"%s\n", $(NF-1)}' file_list.csv |awk -F\\ '{print $NF}'|while read file
do
   grep -q $file log.txt
   if [ $? -eq 0 ]
   then
         printf "*%s",$file
   else
         printf "%s",$file
   fi
done >new_file_list.csv

The format you have mentioned for file_list.csv is not in csv that looks like a tab seperated.

I am not sure how it really looks like.

If it looks like this with commas then replace the first awk with awk -F, '{print $2}'

Code:
*,                 DIR_source\LEAD\LEAD_se.c                      ,         main\1
   ,          DIR_source\LEAD\LEADcommmon\lead_configFile.h ,       main\2
*  ,                DIR_source\LEAD\LEAD_calc.c                          ,  main\3   
     ,               DIR_source\TEA\TEA_tail.c                            ,main\2

How this time it works for you.
# 13  
Old 08-17-2010
In .csv file it looks like this: (In Microsfot word 2003)

Code:
  ;DIR_source\TEA\TEA_cam.c\.;\main\base2ucm_source\600_int\1
  ;DIR_source\TEA\TEA_make.c;\main\base2ucm_source\600_int\2
*;DIR_source\TEA\TEAcommon;\main\base2ucm_source\600_int\3
  ;DIR_source\TEA\Makefile;\main\base2ucm_source\600_int\1
*;DIR_source\LENT\LENT_cam.c;\main\base2ucm_source\600_int\11
  ;DIR_source\LENT\LENT_make.h;\main\base2ucm_source\600_int\10
  ;DIR_source\AXP\AXP_cam.c;\main\base2ucm_source\600_int\9
  ;DIR_source\AXP\AXP_rent.c;\main\base2ucm_source\600_int\1
  ;DIR_source\AXP\AXP_gui.h;\main\base2ucm_source\600_int\1
*;DIR_source\AAP\AAP_tsc.c;\main\base2ucm_source\600_int\13
  ;DIR_source\AAP\AAP_ms.c;\main\base2ucm_source\600_int\1
  ;DIR_source\AAP\AAP_wq.h;\main\base2ucm_source\600_int\1

# 14  
Old 08-18-2010
should we check the file if it has already * ?
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Creating the script for updating or replacing the existing http.conf file

Hi I need some help with a task, i am an absolute newbie to any form of shell scripting and request guidance. I have been building a proxy server using the apache mod proxy currently my solution is working , but i need to automate the process , suppose if any changes need to be made on... (0 Replies)
Discussion started by: satej
0 Replies

2. Shell Programming and Scripting

bash script to find date based on search string for continuesly updating file

Hi All, I am very new to UNIX and I have tried this for a longtime now and unable to crack it.... There is a file that is continuously updating. I need to search for the string and find the date @ which it updated every day..... eg: String is "work started" The log entry is as below: ... (1 Reply)
Discussion started by: Nithz
1 Replies

3. Shell Programming and Scripting

Updating a CSV file by multiple PERL scripts

Hi Friends, I'm writing code to update a CSV file by multiple PERL scripts. I've around 2000 PERL scripts which need to register their entries into a CSV file. Hence, I'm inserting following line code in all the 2000 PERL scripts. open(FILE,... (5 Replies)
Discussion started by: Lokesha
5 Replies

4. Shell Programming and Scripting

Updating a line in a large csv file, with sed/awk?

I have an extremely large csv file that I need to search the second field, and upon matches update the last field... I can pull the line with awk.. but apparently you cant use awk to directly update the file? So im curious if I can use sed to do this... The good news is the field I want to... (5 Replies)
Discussion started by: trey85stang
5 Replies

5. Shell Programming and Scripting

awk updating one file with another, comparing, updating

Hello, I read and search through this wonderful forum and tried different approaches but it seems I lack some knowledge and neurones ^^ Here is what I'm trying to achieve : file1: test filea 3495; test fileb 4578; test filec 7689; test filey 9978; test filez 12300; file2: test filea... (11 Replies)
Discussion started by: mecano
11 Replies

6. Shell Programming and Scripting

script for updating table using file(

Hi, Data file path (.txt) Control file(.ctl) I have delimited file(|). Sample data: 1|name|50009|DS24|0|12 2|name|30009|DS24|0|13 3|name|20409|DS24|0|14 4|name|20009|DS24|0|15 5|name|10009|DS24|0|16 I want to load this data into a oracle table (update and insert) Please help me... (1 Reply)
Discussion started by: unihp1
1 Replies

7. UNIX for Advanced & Expert Users

Updating a csv file held on a unix box with excel running on windows

Hi, my question is quite simple: Can I update a csv file which is held on a unix box (and which a script on the same box uses) with Microsoft Excel running in a windows environment? Or, is there a free spreadsheet package available to run in unix that will update my csv file. I know it's easy to... (5 Replies)
Discussion started by: Sn33R
5 Replies
Login or Register to Ask a Question