-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Kathryn Paradis edited this page Jan 17, 2018
·
6 revisions
- Once you have a CSV containing the missing data, you will need to reformat it to be able to upload it to the database.
- Open the CSV in Excel
- Delete any unnecessary columns
- You will need to insert a column including a PurposeId for all rows of data. You can do this one of two ways:
- Basic method
- Insert a new column (move it to the leftmost column if it isn't already there).
- Scroll down to the last row of data, and insert your PurposeId in the last row.
- Copy your PurposeId.
- Press Ctrl + Shift + upward arrow key to select all the rows with data.
- Paste your PurposeId into all of the selected rows.
- Tableau Add-on (if you haven't installed this add-on you will need to for this method)
-
Type in the purpose ID as the header for one of the columns (see image):
-
Select the cell directly beneath the purpose ID and go to the Tableau tab on Excel, and click the "Reshape data" button on the top left where the cursor can be seen in the image below:
-
Click ok
-
A new worksheet will pop up with your reshaped data:
-
Delete the original worksheet. (When you go to save the CSV it only saves the 1st worksheet.)
-
- Basic method
- Order the columns as they appear in the table you wish to insert the data into.
- Save the file
- Open SQL shell
- Press enter to get into LocalHost
- Type the database name
- Enter the port number from Local Forwarding.
- Type in your Putty username
- Use the \copy command to upload your CSV (see example below):
\copy tablename (column1, column2, column3) from 'C:\Users\Kat\Desktop\filename.csv' CSV HEADER;
- Your data is now uploaded to the database!
- Open winSCP
- Find the folder that you want to put your file in, and place your file in the folder.
- Once the file is in the folder, copy the file address to use in the \copy command that you will use in the next steps [You can right click the file, mouse over File Names, and select "Copy to Clipboard (include paths)"]
- Putty into the server
- Type the following: psql databasename (type the name of the database that you want to upload the data to)
- Paste the following (*make sure the file address that you previously copied is from the SERVER, NOT your computer):
\copy tablename (column1, column2, column3) from '/home/kathryn/practice_upload/filename.csv' CSV HEADER;
- Your data is now uploaded to the database!
- Add user to role
- Create role with NOINHERIT (so it can be granted to other users without inheriting from anything else)
- Alter permissions table-wise:
- Alter default permissions table-wise: