• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Importing CSV into a postgresql database...

So ive got this xlsx file that I need to put into my database:

2Z05wog.png


Ive exported it to a CSV file and im ready to start making the table that it will be imported into. But ive noticed that the xlsx file has several headings for the same column, for example there is "Water (g)", "WATER" and "Water". I get the feeling that maybe the all caps ones are intended for database use?

Would it be a good idea to copy/paste everything I need into a separate xlsx file with just the all caps headings and make a CSV using just that?
 
Also related question... am I best storing this as a "character varying"? I was going to use whatever postgres has for a floating point for most of this but ive noticed theres some non numeric characters thrown into those columns.
 
Ive figured it out... I rolled with the capitol letters for table headings and I was gonna store it all as varchar but thats a bit crappy. In the future if I wanted to query for all rows with a protein value > x, I wouldn't be able to do that with varchar.

I just replaced all the weird characters and empty spaces with "N" and set the null string to "N" so when it detects these characters on importing it will put a null rather than throw an error. So i can use a numeric type now without it kicking up a fuss when it comes across a non numeric. Sorted 🙂
 
Back
Top