Script for updating a .csv file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script for updating a .csv file
# 1  
Old 08-16-2010
Script for updating a .csv file

Hello guys,

I have one .csv file with all the file names(.c,.h,.sm,.txt etc).....
Now i have compared two baseline in UCM and got a report in .txt file,which looks like this......

Code:
DIFFBL INT_1029_Rel6.0.0.90@\DIR_PVOB STD_6.0.0.50_UCM@\DIR_PVOB (COMPONENT TEXT)
Comparing the following:
  INT_1029_Rel6.0.0.90@\DIR_PVOB
  STD_6.0.0.50_UCM@\DIR_PVOB
Differences:
<<  INT_1029_Rel6.0.0.90 (TEXT)
>>  STD_6.0.0.50_UCM (TEXT)
  none

DIFFBL INT_1029_Rel6.0.0.90@\DIR_PVOB STD_6.0.0.50_UCM@\DIR_PVOB (COMPONENT TEA)
Comparing the following:
  INT_1029_Rel6.0.0.90@\DIR_PVOB
  STD_6.0.0.50_UCM@\DIR_PVOB
Differences:
<< INT_1029_Rel6.0.0.90 (TEA)
>> STD_6.0.0.50_UCM (TEA)
"    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
    M:\shah_view\DIR_source\TEA\TEA_CustomisedArea.c@@\main\base2ucm_source\main\1
    M:\shah_view\DIR_source\TEA\TEA_PowerSupply.c@@\main\base2ucm_source\main\1
    M:\shah_view\DIR_source\TEA\TEA_SDF_Task.c@@\main\base2ucm_source\main\1
    M:\vshah_view\DIR_source\TEA\TEA_private.h@@\main\base2ucm_source\main\1
  M:\shah_view\DIR_source\TEA\TEA_PTT.c@@\main\base2ucm_source\main\1
    M:\shah_view\DIR_source\TEA\TEA_private.h@@\main\base2ucm_source\main\1
    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
    M:\shah_view\DIR_source\TEA\TEA_CustomisedAreaSDF.c@@\main\base2ucm_source\main\1
    M:\shah_view\DIR_source\TEA\TEA_PowerSupply.c@@\main\base2ucm_source\main\1
    M:\shah_view\DIR_source\TEA\TEA_SDF_Task.c@@\main\base2ucm_source\main\1
    M:\shah_view\DIR_source\TEA\TEA_private.h@@\main\base2ucm_source\main\1
  
    M:\shah_view\DIR_source\TEA\TEA_PTT.c@@\main\abase2ucm_source\main\1
    M:\shah_view\DIR_source\TEA\TEA_private.h@@\main\base2ucm_source\main\1
"    M:\shah_view\DIR_source\TEA\TEA_SDF_Task.c@@\main\base2ucm_source\main\1
    M:\shah_view\DIR_source\TEA\TEA_CustomisedAreaSDF.c@@\main\base2ucm_source\main\1
    M:\shah_view\DIR_source\TEA\TEA_CanBusLine.c@@\main\abase2ucm_source\main\1
    M:\shah_view\DIR_source\TEA\CBC_CabinSDmonitoring.c@@\main\base2ucm_source\main\1
    M:\shah_view\DIR_source\TEA\TEA_private.h@@\main\abase2ucm_source\main\2
    M:\shah_view\DIR_source\TEA\TEA_private.h@@\main\abase2ucm_source\main\1
  
    M:\shah_view\DIR_source\TEA\TEA_PowerSupply.c@@\main\abase2ucm_source\main\1
 
    M:\shah_view\DIR_source\TEA\TEA_PTT.c@@\main\base2ucm_source\main\1
  
    M:\shah_view\DIR_source\TEA\TEA_PTT.c@@\main\base2ucm_source\main\1
    M:\shah_view\DIR_source\TEA\TEA_private.h@@\main\base2ucm_source\main\1

DIFFBL INT_1029_Rel6.0.0.90@\DIR_PVOB STD_6.0.0.50_UCM@\DIR_PVOB (COMPONENT KEY)
Comparing the following:
  INT_1029_Rel6.0.0.90@\DIR_PVOB
  STD_6.0.0.50_UCM@\DIR_PVOB
Differences:
<< INT_1029_Rel6.0.0.90 (KEY)
>> STD_6.0.0.50_UCM (KEY)
 
    M:\shah_view\DIR_source\KEY\KEY_chimeController.c@@\main\base2ucm_source\main\1
 
    M:\shah_view\DIR_source\KEY\KEY_chimeController.c@@\main\base2ucm_source\main\1

DIFFBL INT_1029_Rel6.0.0.90.603@\DIR_PVOB STD_6.0.0.50_UCM@\DIR_PVOB (COMPONENT LIMITS)
Comparing the following:
  INT_1029_Rel6.0.0.90@\DIR_PVOB
  STD_6.0.0.50_UCM@\DIR_PVOB
Differences:
<< INT_1029_Rel6.0.0.903 (Limits)
>> STD_6.0.0.50_UCM (Limits)
  none


So here i am getting all the file names which are changed.
SO now i want to put a (*) mark an the .csv file (where the file names are changed.)

Like KEY_chimeController.c will be match in the .csv file.
So now .csv should put a (*) mark in the side column of this file.

Hope you guys understood my requirement...

Waiting for your responses......
# 2  
Old 08-16-2010
file_list.csv is the csv file.
log.txt be the above mentioned file

Code:
file_list=`sed 's\,\ \g' file_list.csv
for file in $file_list
do
   grep -q $file log.txt
   if [ $? -eq 0 ]
   then
         printf "*%s",$file
   else
         printf "%s",$file
   fi
done >new_file_list.csv

I have used just grep to see whether the file has changed or not.

complex conditions shall be added.
# 3  
Old 08-16-2010
Hello Kumar,

Thanks for your reply....
But I did not get..
i am expecting some script which will check for the .c,.h,.txt in the log.txt file and then according to that update in the .csv file...
Hopefully u got my point....
# 4  
Old 08-16-2010
please us know what is the content of your csv file initialy.

my understanding is that csv file will have file names like (test1.c,test.c ....)

if this file is present in the log that you have shown, then we need update that file name as *file_name otherwise keep that file name as it.

if test1.c is present in the log, then the csv file will have *test1.c instead of test1.c

please correct if i am wrong
# 5  
Old 08-16-2010
Hello Kumar,

You are correct....
Your understanding is right......
Will you please help me out to write the script....
# 6  
Old 08-16-2010
then the script must work for you.

What i have tried is, first taken the list of file names present in the csv file.

Then will check each file name present in the log file or not, if present then write that filename with * in a new file.

If not present write that filename as it in the new file.

And later after checking you can rename the new file into csv as you wanted.

Please let me know which one is not working as expected.
# 7  
Old 08-16-2010
Hi,
May be i m wrong but try this
I think in the firstline of command ` is missing in end.
Put it and try u'll definetly get desired answer.

Code:
file_list=`sed 's\,\ \g' file_list.csv`
for file in $file_list
do
   grep -q $file log.txt
   if [ $? -eq 0 ]
   then
         printf "*%s",$file
   else
         printf "%s",$file
   fi
done >new_file_list.csv

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