Difference between revisions of "Eyanosch Week 6"
(adding text to the journal entry. The actions were mainly logged within my Enotes for week 6) |
|||
Line 3: | Line 3: | ||
[[Week 6]] | [[Week 6]] | ||
+ | === Application === | ||
+ | After downloading the zip files and unzipping them I need to rework the files so they can be loaded into postgreSQL | ||
+ | eyanosch@ab201:~$ cat application.txt | sed "s/ *//g" | sed "s/\t/ /g" | ||
+ | |||
+ | # pulls up information, removes the spaces, and removes the tabs. Adds a space inbetween each column | ||
+ | |||
+ | cat application.txt | sed "s/. /&,/g"| sed "s/ *//g" | sed "s/\t/ /g" | ||
+ | |||
+ | eyanosch@ab201:~$ cat application.txt | sed "s/ *//g" | sed "s/\t/ /g" | sed "s/ /' /g" | sed "s/. /&'/g" | sed "s/ /,&/g" | sed "s/\r$/'/g" | sed "s/^/&'/g" | sed "s/''/null/g" | ||
+ | |||
+ | I had to add ' behind and infront of every character and then the empty spaces that were '' I replaced with the word null | ||
+ | |||
+ | |||
+ | cat application.txt | sed "s/ *//g" | sed "s/\t/ /g" | sed "s/ /' /g" | sed "s/. /&'/g" | sed "s/ /,&/g" | sed "s/\r$/');/g" | sed "s/^/&'/g" | sed "s/''/null/g" |sed "s/^/insert into Application(ApplNo, ApplType, SponsorApplicant, MostRecentLabelAvailableFlag, CurrentPatentFlag, ActionType, Chemical_Type, Ther_Potential, Orphan_Code) values (/g" | sed "1D" > ~/public_html/application.sql.txt | ||
+ | |||
+ | This should give the proper syntax for adding from the database the SQL | ||
+ | |||
+ | === Product == | ||
+ | |||
+ | cat Product.txt | sed "s/'/\"/g" | sed "s/ *//g" | sed "s/\t/ /g" | sed "s/ /' /g" | sed "s/. /&'/g" | sed "s/ /,&/g" | sed "s/\r$/');/g" | sed "s/^/&'/g" | sed "s/''/null/g" | sed "s/^/insert into product(ApplNo, ProductNo, Form, Dosage, productMktStatus, TECode, ReferenceDrug, drugname, activeingred) values (/g" | sed "1D" > ~/public_html/Product.sql.txt | ||
+ | |||
+ | Apply the same principle but there were 's within the text so I changed them into " and replaced them with null | ||
+ | |||
+ | Ran the program in SQL: | ||
+ | Query returned successfully: one row affected, 4916 ms execution time. | ||
Revision as of 03:29, 15 October 2015
Application
After downloading the zip files and unzipping them I need to rework the files so they can be loaded into postgreSQL
eyanosch@ab201:~$ cat application.txt | sed "s/ *//g" | sed "s/\t/ /g"
- pulls up information, removes the spaces, and removes the tabs. Adds a space inbetween each column
cat application.txt | sed "s/. /&,/g"| sed "s/ *//g" | sed "s/\t/ /g"
eyanosch@ab201:~$ cat application.txt | sed "s/ *//g" | sed "s/\t/ /g" | sed "s/ /' /g" | sed "s/. /&'/g" | sed "s/ /,&/g" | sed "s/\r$/'/g" | sed "s/^/&'/g" | sed "s//null/g"
I had to add ' behind and infront of every character and then the empty spaces that were I replaced with the word null
cat application.txt | sed "s/ *//g" | sed "s/\t/ /g" | sed "s/ /' /g" | sed "s/. /&'/g" | sed "s/ /,&/g" | sed "s/\r$/');/g" | sed "s/^/&'/g" | sed "s//null/g" |sed "s/^/insert into Application(ApplNo, ApplType, SponsorApplicant, MostRecentLabelAvailableFlag, CurrentPatentFlag, ActionType, Chemical_Type, Ther_Potential, Orphan_Code) values (/g" | sed "1D" > ~/public_html/application.sql.txt
This should give the proper syntax for adding from the database the SQL
= Product
cat Product.txt | sed "s/'/\"/g" | sed "s/ *//g" | sed "s/\t/ /g" | sed "s/ /' /g" | sed "s/. /&'/g" | sed "s/ /,&/g" | sed "s/\r$/');/g" | sed "s/^/&'/g" | sed "s//null/g" | sed "s/^/insert into product(ApplNo, ProductNo, Form, Dosage, productMktStatus, TECode, ReferenceDrug, drugname, activeingred) values (/g" | sed "1D" > ~/public_html/Product.sql.txt
Apply the same principle but there were 's within the text so I changed them into " and replaced them with null
Ran the program in SQL:
Query returned successfully: one row affected, 4916 ms execution time.
Class Journals
Weekly Assignments
Personal Journal
Eyanosch Week 6
Electronic Notes (E-notes)
Class (personal) Notes