Difference between revisions of "Troque Week 6"
From LMU BioDB 2015
(Added new version of sed commands) |
(Added my solution for formatting the data for application.txt) |
||
Line 5: | Line 5: | ||
== Processing the Data on the Command Line == | == Processing the Data on the Command Line == | ||
+ | |||
+ | cat application.txt | | ||
+ | sed "s/\t/,/g" | | ||
+ | sed "s/,/,'/1" | | ||
+ | sed "s/,'[A-Z]/&'/1" | | ||
+ | sed "s/,/,'/2" | | ||
+ | sed "s/\s*,False/',False/1" | | ||
+ | sed "s/,/,'/5 " | | ||
+ | sed "s/,/',/6" | | ||
+ | sed "s/,,/,null,/" | | ||
+ | sed "s/,,/,null,/" | | ||
+ | sed "s/,\r$/,null/g" | | ||
+ | sed "s/,S,/,'S',/g" | | ||
+ | sed "s/,P,/,'P',/g" | | ||
+ | sed "s/,V/,'V'/g" | | ||
+ | sed "s/P\*/'P\*'/g" | | ||
+ | sed "s/S\*/'S\*'/g" | | ||
+ | sed "s/,AP,/,'AP',/g" | | ||
+ | sed "s/$/);/g" | | ||
+ | sed "s/^/insert into application (ApplNo,ApplType,SponsorApplicant,MostRecentLabelFlag, | ||
+ | CurrentPatentFlag,ActionType,ChemicalType,Ther_Potential, | ||
+ | OrphanCode) values (/g" | | ||
+ | sed "1d" > ~/public_html/application.sql.txt | ||
+ | |||
+ | From doing this assignment, I realized how badly formatted it is. | ||
<!-- cat application.txt | | <!-- cat application.txt | | ||
Line 29: | Line 54: | ||
sed "s/\t//g" | | sed "s/\t//g" | | ||
sed "s/[0-9],null/&,null/" | | sed "s/[0-9],null/&,null/" | | ||
− | sed "s/^/insert into application (ApplNo,ApplType,SponsorApplicant,MostRecentLabelFlag, | + | sed "s/^/insert into application (ApplNo,ApplType,SponsorApplicant,MostRecentLabelFlag,CurrentPatentFlag,ActionType,ChemicalType,Ther_Potential,OrphanCode) values (/g" | |
− | + | ||
− | + | ||
sed "s/\r$/);/" | | sed "s/\r$/);/" | | ||
sed "s/null$/&);/g" | | sed "s/null$/&);/g" | | ||
sed "s/'V'$/&);/" > ~/public_html/application.sql.txt | sed "s/'V'$/&);/" > ~/public_html/application.sql.txt | ||
− | |||
− | |||
− | |||
--> | --> | ||
{{Template:Troque_Journal}} | {{Template:Troque_Journal}} |
Revision as of 23:27, 14 October 2015
Contents
Creating the Table on PostgreSQL
Processing the Data on the Command Line
cat application.txt | sed "s/\t/,/g" | sed "s/,/,'/1" | sed "s/,'[A-Z]/&'/1" | sed "s/,/,'/2" | sed "s/\s*,False/',False/1" | sed "s/,/,'/5 " | sed "s/,/',/6" | sed "s/,,/,null,/" | sed "s/,,/,null,/" | sed "s/,\r$/,null/g" | sed "s/,S,/,'S',/g" | sed "s/,P,/,'P',/g" | sed "s/,V/,'V'/g" | sed "s/P\*/'P\*'/g" | sed "s/S\*/'S\*'/g" | sed "s/,AP,/,'AP',/g" | sed "s/$/);/g" | sed "s/^/insert into application (ApplNo,ApplType,SponsorApplicant,MostRecentLabelFlag, CurrentPatentFlag,ActionType,ChemicalType,Ther_Potential, OrphanCode) values (/g" | sed "1d" > ~/public_html/application.sql.txt
From doing this assignment, I realized how badly formatted it is.
Assignment Links
Weekly Assignments
- Week 1
- Week 2
- Week 3
- Week 4
- Week 5
- Week 6
- Week 7
- Week 8
- Week 9
- Week 10
- Week 11
- Week 12
- No Week 13 Assignment
- Week 14
- Week 15
Individual Journal Entries
- Week 1 - This is technically the user page.
- Week 2
- Week 3
- Week 4
- Week 5
- Week 6
- Week 7
- Week 8
- Week 9
- Week 10
- Week 11
- Week 12
- No Week 13 Assignment
- Week 14
- Week 15