Skip to content

Instantly share code, notes, and snippets.

@korczis
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save korczis/2f7f54c7bd53554f44df to your computer and use it in GitHub Desktop.
Save korczis/2f7f54c7bd53554f44df to your computer and use it in GitHub Desktop.

csv2psql CLI examples

Enjoy them

List

  • Census 2010 as table
  • Census 2010 as SQL
  • CIA Factbook as table
  • CIA Factbook as SQL
  • SFPD as table
  • SFPD as SQL
csv2psql schema -f table ./data/census_SFOH_2010.csv

+-------------------------------------------------+---------+---------+
|                     ./data/census_SFOH_2010.csv                     |
+-------------------------------------------------+---------+---------+
| column                                          | type    | null    |
+-------------------------------------------------+---------+---------+
| MSA                                             | text    | false   |
| Tract ID                                        | bigint  | false   |
| White Alone                                     | bigint  | false   |
| Black or African American alone                 | bigint  | false   |
| Asian alone                                     | bigint  | false   |
| Family Households                               | bigint  | false   |
| Nonfamily Households                            | bigint  | false   |
| Household income: < 10k                         | bigint  | false   |
| Household income: 10-15k                        | bigint  | false   |
| Household income: 15-20k                        | bigint  | false   |
| Household income: 20-25k                        | bigint  | false   |
| Household income: 25-30k                        | bigint  | false   |
| Household income: 30-35k                        | bigint  | false   |
| Household income: 35-40k                        | bigint  | false   |
| Household income: 40-45k                        | bigint  | false   |
| Household income: 45-50k                        | bigint  | false   |
| Household income: 50-60k                        | bigint  | false   |
| Household income: 60-75k                        | bigint  | false   |
| Household income: 75-100k                       | bigint  | false   |
| Household income: 100-125k                      | bigint  | false   |
| Household income: 125-150k                      | bigint  | false   |
| Household income: 150-200k                      | bigint  | false   |
| Household income: > 200k                        | bigint  | false   |
| With wage or salary income                      | bigint  | false   |
| No wage or salary income                        | bigint  | false   |
| With self-employment income                     | bigint  | false   |
| No self-employment income                       | bigint  | false   |
| With interest dividends or net rental income    | bigint  | false   |
| No interest dividends or net rental income      | bigint  | false   |
| With Social Security income                     | bigint  | false   |
| No Social Security income                       | bigint  | false   |
| With Supplemental Security Income (SSI)         | bigint  | false   |
| No Supplemental Security Income (SSI)           | bigint  | false   |
| With public assistance income                   | bigint  | false   |
| No public assistance income                     | bigint  | false   |
| With cash public assistance or Food Stamps/SNAP | bigint  | false   |
| No cash public assistance or Food Stamps/SNAP   | bigint  | false   |
| With retirement income                          | bigint  | false   |
| No retirement income                            | bigint  | false   |
| Per capita income (2010 dollars)                | bigint  | true    |
| Housing units                                   | bigint  | false   |
| Occupancy status: Occupied                      | bigint  | false   |
| Occupancy status: Vacant                        | bigint  | false   |
| Housing tenure: Owner-occupied                  | bigint  | false   |
| Housing tenure: Renter-occupied                 | bigint  | false   |
| Median number of rooms                          | decimal | true    |
| Median gross rent (dollars)                     | bigint  | true    |
| Median value for owner-occupied housing         | bigint  | true    |
+-------------------------------------------------+---------+---------+
-- csv2psql schema -f sql ./data/census_SFOH_2010.csv
CREATE TABLE my_table(
"msa" TEXT NOT NULL,
"tract_id" BIGINT NOT NULL,
"white_alone" BIGINT NOT NULL,
"black_or_african_american_alone" BIGINT NOT NULL,
"asian_alone" BIGINT NOT NULL,
"family_households" BIGINT NOT NULL,
"nonfamily_households" BIGINT NOT NULL,
"household_income_10k" BIGINT NOT NULL,
"household_income_10_15k" BIGINT NOT NULL,
"household_income_15_20k" BIGINT NOT NULL,
"household_income_20_25k" BIGINT NOT NULL,
"household_income_25_30k" BIGINT NOT NULL,
"household_income_30_35k" BIGINT NOT NULL,
"household_income_35_40k" BIGINT NOT NULL,
"household_income_40_45k" BIGINT NOT NULL,
"household_income_45_50k" BIGINT NOT NULL,
"household_income_50_60k" BIGINT NOT NULL,
"household_income_60_75k" BIGINT NOT NULL,
"household_income_75_100k" BIGINT NOT NULL,
"household_income_100_125k" BIGINT NOT NULL,
"household_income_125_150k" BIGINT NOT NULL,
"household_income_150_200k" BIGINT NOT NULL,
"household_income_200k" BIGINT NOT NULL,
"with_wage_or_salary_income" BIGINT NOT NULL,
"no_wage_or_salary_income" BIGINT NOT NULL,
"with_self_employment_income" BIGINT NOT NULL,
"no_self_employment_income" BIGINT NOT NULL,
"with_interest_dividends_or_net_rental_income" BIGINT NOT NULL,
"no_interest_dividends_or_net_rental_income" BIGINT NOT NULL,
"with_social_security_income" BIGINT NOT NULL,
"no_social_security_income" BIGINT NOT NULL,
"with_supplemental_security_income_ssi" BIGINT NOT NULL,
"no_supplemental_security_income_ssi" BIGINT NOT NULL,
"with_public_assistance_income" BIGINT NOT NULL,
"no_public_assistance_income" BIGINT NOT NULL,
"with_cash_public_assistance_or_food_stamps_snap" BIGINT NOT NULL,
"no_cash_public_assistance_or_food_stamps_snap" BIGINT NOT NULL,
"with_retirement_income" BIGINT NOT NULL,
"no_retirement_income" BIGINT NOT NULL,
"per_capita_income_2010_dollars" BIGINT,
"housing_units" BIGINT NOT NULL,
"occupancy_status_occupied" BIGINT NOT NULL,
"occupancy_status_vacant" BIGINT NOT NULL,
"housing_tenure_owner_occupied" BIGINT NOT NULL,
"housing_tenure_renter_occupied" BIGINT NOT NULL,
"median_number_of_rooms" DECIMAL,
"median_gross_rent_dollars" BIGINT,
"median_value_for_owner_occupied_housing" BIGINT
)
WITH (
OIDS=FALSE
);
-- real 0m2.564s
-- user 0m2.236s
-- sys 0m0.108s
csv2psql schema -f table ./data/cia-data-all.csv

+------------------------------------------------------------------+---------+--------+
|                               ./data/cia-data-all.csv                               |
+------------------------------------------------------------------+---------+--------+
| column                                                           | type    | null   |
+------------------------------------------------------------------+---------+--------+
| id                                                               | text    | false  |
| Labor force                                                      | bigint  | true   |
| Labor force details                                              | text    | true   |
| Judicial branch                                                  | text    | true   |
| Land use                                                         | decimal | true   |
| Land use details                                                 | text    | true   |
| Land boundaries                                                  | decimal | true   |
| Land boundaries details                                          | text    | true   |
| Infant mortality rate                                            | decimal | true   |
| Infant mortality rate details                                    | text    | true   |
| Industries                                                       | text    | true   |
| Waterways                                                        | bigint  | true   |
| Waterways details                                                | bigint  | true   |
| Inflation rate (consumer prices)                                 | decimal | true   |
| Inflation rate (consumer prices) details                         | text    | true   |
| Languages                                                        | decimal | true   |
| Languages details                                                | text    | true   |
| Internet country code                                            | text    | true   |
| HIV/AIDS - adult prevalence rate                                 | decimal | true   |
| HIV/AIDS - adult prevalence rate details                         | text    | true   |
| HIV/AIDS - people living with HIV/AIDS                           | bigint  | true   |
| HIV/AIDS - people living with HIV/AIDS details                   | text    | true   |
| HIV/AIDS - deaths                                                | bigint  | true   |
| HIV/AIDS - deaths details                                        | text    | true   |
| Telephones - main lines in use                                   | bigint  | true   |
| Telephones - main lines in use details                           | text    | true   |
| Sex ratio                                                        | decimal | true   |
| Sex ratio details                                                | text    | true   |
| Internet users                                                   | bigint  | true   |
| Internet users details                                           | text    | true   |
| Television broadcast stations                                    | decimal | true   |
| Television broadcast stations details                            | text    | true   |
| Geographic coordinates                                           | text    | true   |
| Age structure                                                    | decimal | true   |
| Age structure details                                            | text    | true   |
| Radio broadcast stations                                         | decimal | true   |
| Radio broadcast stations details                                 | text    | true   |
| GDP - composition by sector                                      | decimal | true   |
| GDP - composition by sector details                              | text    | true   |
| Disputes - international                                         | text    | true   |
| Area                                                             | bigint  | true   |
| Area details                                                     | text    | true   |
| Irrigated land                                                   | decimal | true   |
| Irrigated land details                                           | text    | true   |
| Map references                                                   | text    | true   |
| Location                                                         | text    | true   |
| Country name                                                     | text    | true   |
| Coastline                                                        | decimal | true   |
| Coastline details                                                | text    | true   |
| Imports - partners                                               | decimal | true   |
| Imports - partners details                                       | text    | true   |
| Constitution                                                     | text    | true   |
| Diplomatic representation in the US                              | text    | true   |
| Manpower reaching militarily significant age annually            | decimal | true   |
| Manpower reaching militarily significant age annually details    | text    | true   |
| Distribution of family income - Gini index                       | decimal | true   |
| Distribution of family income - Gini index details               | text    | true   |
| Oil - production                                                 | bigint  | true   |
| Oil - production details                                         | text    | true   |
| Debt - external                                                  | text    | true   |
| Debt - external details                                          | text    | true   |
| Exports                                                          | text    | true   |
| Exports details                                                  | text    | true   |
| Oil - exports                                                    | bigint  | true   |
| Oil - exports details                                            | text    | true   |
| Median age                                                       | decimal | true   |
| Median age details                                               | text    | true   |
| Oil - consumption                                                | bigint  | true   |
| Oil - consumption details                                        | text    | true   |
| Oil - imports                                                    | bigint  | true   |
| Oil - imports details                                            | text    | true   |
| Oil - proved reserves                                            | bigint  | true   |
| Oil - proved reserves details                                    | text    | true   |
| Natural gas - proved reserves                                    | bigint  | true   |
| Natural gas - proved reserves details                            | text    | true   |
| Executive branch                                                 | text    | true   |
| Exchange rates                                                   | decimal | true   |
| Exchange rates details                                           | text    | true   |
| Ethnic groups                                                    | decimal | true   |
| Ethnic groups details                                            | text    | true   |
| Market value of publicly traded shares                           | text    | true   |
| Market value of publicly traded shares details                   | text    | true   |
| Exports - partners                                               | decimal | true   |
| Exports - partners details                                       | text    | true   |
| Airports                                                         | bigint  | true   |
| Airports details                                                 | bigint  | true   |
| School life expectancy (primary to tertiary education)           | decimal | true   |
| School life expectancy (primary to tertiary education) details   | bigint  | true   |
| Population below poverty line                                    | decimal | true   |
| Population below poverty line details                            | text    | true   |
| Household income or consumption by percentage share              | decimal | true   |
| Household income or consumption by percentage share details      | text    | true   |
| Electricity - exports                                            | decimal | true   |
| Electricity - exports details                                    | text    | true   |
| Electricity - consumption                                        | bigint  | true   |
| Electricity - consumption details                                | text    | true   |
| Capital                                                          | text    | true   |
| Background                                                       | text    | true   |
| Labor force - by occupation                                      | decimal | true   |
| Labor force - by occupation details                              | text    | true   |
| Exports - commodities                                            | text    | true   |
| Commercial bank prime lending rate                               | decimal | true   |
| Commercial bank prime lending rate details                       | text    | true   |
| Death rate                                                       | decimal | true   |
| Death rate details                                               | text    | true   |
| Pipelines                                                        | decimal | true   |
| Pipelines details                                                | bigint  | true   |
| GDP (official exchange rate)                                     | text    | true   |
| GDP (official exchange rate) details                             | text    | true   |
| Stock of direct foreign investment - at home                     | text    | true   |
| Stock of direct foreign investment - at home details             | text    | true   |
| Stock of direct foreign investment - abroad                      | text    | true   |
| Stock of direct foreign investment - abroad details              | text    | true   |
| Administrative divisions                                         | text    | true   |
| Total renewable water resources                                  | decimal | true   |
| Total renewable water resources details                          | bigint  | true   |
| Freshwater withdrawal (domestic/industrial/agricultural)         | decimal | true   |
| Freshwater withdrawal (domestic/industrial/agricultural) details | bigint  | true   |
| Agriculture - products                                           | text    | true   |
| Military branches                                                | text    | true   |
| Birth rate                                                       | decimal | true   |
| Birth rate details                                               | text    | true   |
| Education expenditures                                           | decimal | true   |
| Education expenditures details                                   | bigint  | true   |
| Budget                                                           | text    | true   |
| Budget details                                                   | text    | true   |
| Climate                                                          | text    | true   |
| Imports - commodities                                            | text    | true   |
| Political parties and leaders                                    | text    | true   |
| Population                                                       | bigint  | true   |
| Population details                                               | text    | true   |
| Nationality                                                      | text    | true   |
| Natural resources                                                | text    | true   |
| Net migration rate                                               | decimal | true   |
| Net migration rate details                                       | text    | true   |
| Geography - note                                                 | text    | true   |
| Political pressure groups and leaders                            | text    | true   |
| Economy - overview                                               | text    | true   |
| Telephones - mobile cellular                                     | bigint  | true   |
| Telephones - mobile cellular details                             | text    | true   |
| Independence                                                     | text    | true   |
| Natural gas - exports                                            | bigint  | true   |
| Natural gas - exports details                                    | text    | true   |
| Natural gas - imports                                            | bigint  | true   |
| Natural gas - imports details                                    | text    | true   |
| Natural gas - consumption                                        | bigint  | true   |
| Natural gas - consumption details                                | text    | true   |
| Religions                                                        | decimal | true   |
| Religions details                                                | text    | true   |
| Current account balance                                          | text    | true   |
| Current account balance details                                  | text    | true   |
| Public debt                                                      | uuid    | true   |
| Public debt details                                              | uuid    | true   |
| Investment (gross fixed)                                         | uuid    | true   |
| Investment (gross fixed) details                                 | uuid    | true   |
| Internet hosts                                                   | uuid    | true   |
| Internet hosts details                                           | uuid    | true   |
| Reserves of foreign exchange and gold                            | uuid    | true   |
| Reserves of foreign exchange and gold details                    | uuid    | true   |
| Electricity - imports                                            | decimal | true   |
| Electricity - imports details                                    | text    | true   |
| Urbanization                                                     | decimal | true   |
| Urbanization details                                             | text    | true   |
| Stock of domestic credit                                         | text    | true   |
| Stock of domestic credit details                                 | text    | true   |
| Military service age and obligation                              | bigint  | true   |
| Military service age and obligation details                      | uuid    | true   |
| Manpower fit for military service                                | decimal | true   |
| Manpower fit for military service details                        | text    | true   |
| National holiday                                                 | text    | true   |
| Merchant marine                                                  | bigint  | true   |
| Merchant marine details                                          | bigint  | true   |
| Elevation extremes                                               | decimal | true   |
| Elevation extremes details                                       | text    | true   |
| Natural hazards                                                  | text    | true   |
| Area - comparative                                               | text    | true   |
| Literacy                                                         | decimal | true   |
| Literacy details                                                 | text    | true   |
| Life expectancy at birth                                         | decimal | true   |
| Life expectancy at birth details                                 | text    | true   |
| Legislative branch                                               | text    | true   |
| Legal system                                                     | text    | true   |
| International organization participation                         | text    | true   |
| Maritime claims                                                  | decimal | true   |
| Maritime claims details                                          | text    | true   |
| Manpower available for military service                          | decimal | true   |
| Manpower available for military service details                  | text    | true   |
| Military expenditures                                            | decimal | true   |
| Military expenditures details                                    | text    | true   |
| Environment - international agreements                           | text    | true   |
| Environment - current issues                                     | text    | true   |
| Airports - with unpaved runways                                  | decimal | true   |
| Airports - with unpaved runways details                          | bigint  | true   |
| Airports - with paved runways                                    | decimal | true   |
| Airports - with paved runways details                            | bigint  | true   |
| Electricity - production                                         | bigint  | true   |
| Electricity - production details                                 | text    | true   |
| Railways                                                         | bigint  | true   |
| Railways details                                                 | bigint  | true   |
| Ports and terminals                                              | text    | true   |
| Suffrage                                                         | decimal | true   |
| Suffrage details                                                 | text    | true   |
| Industrial production growth rate                                | decimal | true   |
| Industrial production growth rate details                        | text    | true   |
| Terrain                                                          | text    | true   |
| Telephone system                                                 | text    | true   |
| Total fertility rate                                             | decimal | true   |
| Total fertility rate details                                     | text    | true   |
| Unemployment rate                                                | decimal | true   |
| Unemployment rate details                                        | text    | true   |
| Government type                                                  | text    | true   |
| Flag description                                                 | text    | true   |
| Illicit drugs                                                    | text    | true   |
| Imports                                                          | text    | true   |
| Imports details                                                  | text    | true   |
| Roadways                                                         | bigint  | true   |
| Roadways details                                                 | bigint  | true   |
| Population growth rate                                           | decimal | true   |
| Population growth rate details                                   | text    | true   |
| GDP - real growth rate                                           | decimal | true   |
| GDP - real growth rate details                                   | text    | true   |
| Heliports                                                        | decimal | true   |
| Heliports details                                                | bigint  | true   |
| GDP (purchasing power parity)                                    | text    | true   |
| GDP (purchasing power parity) details                            | text    | true   |
| Diplomatic representation from the US                            | text    | true   |
| GDP - per capita (PPP)                                           | text    | true   |
| GDP - per capita (PPP) details                                   | text    | true   |
| Natural gas - production                                         | bigint  | true   |
| Natural gas - production details                                 | text    | true   |
+------------------------------------------------------------------+---------+--------+

real	0m4.928s
user	0m4.670s
sys	0m0.087s
-- csv2psql schema -f sql ./data/cia-data-all.csv
CREATE TABLE my_table(
"id" TEXT NOT NULL,
"labor_force" BIGINT,
"labor_force_details" TEXT,
"judicial_branch" TEXT,
"land_use" DECIMAL,
"land_use_details" TEXT,
"land_boundaries" DECIMAL,
"land_boundaries_details" TEXT,
"infant_mortality_rate" DECIMAL,
"infant_mortality_rate_details" TEXT,
"industries" TEXT,
"waterways" BIGINT,
"waterways_details" BIGINT,
"inflation_rate_consumer_prices" DECIMAL,
"inflation_rate_consumer_prices_details" TEXT,
"languages" DECIMAL,
"languages_details" TEXT,
"internet_country_code" TEXT,
"hiv_aids_adult_prevalence_rate" DECIMAL,
"hiv_aids_adult_prevalence_rate_details" TEXT,
"hiv_aids_people_living_with_hiv_aids" BIGINT,
"hiv_aids_people_living_with_hiv_aids_details" TEXT,
"hiv_aids_deaths" BIGINT,
"hiv_aids_deaths_details" TEXT,
"telephones_main_lines_in_use" BIGINT,
"telephones_main_lines_in_use_details" TEXT,
"sex_ratio" DECIMAL,
"sex_ratio_details" TEXT,
"internet_users" BIGINT,
"internet_users_details" TEXT,
"television_broadcast_stations" DECIMAL,
"television_broadcast_stations_details" TEXT,
"geographic_coordinates" TEXT,
"age_structure" DECIMAL,
"age_structure_details" TEXT,
"radio_broadcast_stations" DECIMAL,
"radio_broadcast_stations_details" TEXT,
"gdp_composition_by_sector" DECIMAL,
"gdp_composition_by_sector_details" TEXT,
"disputes_international" TEXT,
"area" BIGINT,
"area_details" TEXT,
"irrigated_land" DECIMAL,
"irrigated_land_details" TEXT,
"map_references" TEXT,
"location" TEXT,
"country_name" TEXT,
"coastline" DECIMAL,
"coastline_details" TEXT,
"imports_partners" DECIMAL,
"imports_partners_details" TEXT,
"constitution" TEXT,
"diplomatic_representation_in_the_us" TEXT,
"manpower_reaching_militarily_significant_age_annually" DECIMAL,
"manpower_reaching_militarily_significant_age_annually_details" TEXT,
"distribution_of_family_income_gini_index" DECIMAL,
"distribution_of_family_income_gini_index_details" TEXT,
"oil_production" BIGINT,
"oil_production_details" TEXT,
"debt_external" TEXT,
"debt_external_details" TEXT,
"exports" TEXT,
"exports_details" TEXT,
"oil_exports" BIGINT,
"oil_exports_details" TEXT,
"median_age" DECIMAL,
"median_age_details" TEXT,
"oil_consumption" BIGINT,
"oil_consumption_details" TEXT,
"oil_imports" BIGINT,
"oil_imports_details" TEXT,
"oil_proved_reserves" BIGINT,
"oil_proved_reserves_details" TEXT,
"natural_gas_proved_reserves" BIGINT,
"natural_gas_proved_reserves_details" TEXT,
"executive_branch" TEXT,
"exchange_rates" DECIMAL,
"exchange_rates_details" TEXT,
"ethnic_groups" DECIMAL,
"ethnic_groups_details" TEXT,
"market_value_of_publicly_traded_shares" TEXT,
"market_value_of_publicly_traded_shares_details" TEXT,
"exports_partners" DECIMAL,
"exports_partners_details" TEXT,
"airports" BIGINT,
"airports_details" BIGINT,
"school_life_expectancy_primary_to_tertiary_education" DECIMAL,
"school_life_expectancy_primary_to_tertiary_education_details" BIGINT,
"population_below_poverty_line" DECIMAL,
"population_below_poverty_line_details" TEXT,
"household_income_or_consumption_by_percentage_share" DECIMAL,
"household_income_or_consumption_by_percentage_share_details" TEXT,
"electricity_exports" DECIMAL,
"electricity_exports_details" TEXT,
"electricity_consumption" BIGINT,
"electricity_consumption_details" TEXT,
"capital" TEXT,
"background" TEXT,
"labor_force_by_occupation" DECIMAL,
"labor_force_by_occupation_details" TEXT,
"exports_commodities" TEXT,
"commercial_bank_prime_lending_rate" DECIMAL,
"commercial_bank_prime_lending_rate_details" TEXT,
"death_rate" DECIMAL,
"death_rate_details" TEXT,
"pipelines" DECIMAL,
"pipelines_details" BIGINT,
"gdp_official_exchange_rate" TEXT,
"gdp_official_exchange_rate_details" TEXT,
"stock_of_direct_foreign_investment_at_home" TEXT,
"stock_of_direct_foreign_investment_at_home_details" TEXT,
"stock_of_direct_foreign_investment_abroad" TEXT,
"stock_of_direct_foreign_investment_abroad_details" TEXT,
"administrative_divisions" TEXT,
"total_renewable_water_resources" DECIMAL,
"total_renewable_water_resources_details" BIGINT,
"freshwater_withdrawal_domestic_industrial_agricultural" DECIMAL,
"freshwater_withdrawal_domestic_industrial_agricultural_details" BIGINT,
"agriculture_products" TEXT,
"military_branches" TEXT,
"birth_rate" DECIMAL,
"birth_rate_details" TEXT,
"education_expenditures" DECIMAL,
"education_expenditures_details" BIGINT,
"budget" TEXT,
"budget_details" TEXT,
"climate" TEXT,
"imports_commodities" TEXT,
"political_parties_and_leaders" TEXT,
"population" BIGINT,
"population_details" TEXT,
"nationality" TEXT,
"natural_resources" TEXT,
"net_migration_rate" DECIMAL,
"net_migration_rate_details" TEXT,
"geography_note" TEXT,
"political_pressure_groups_and_leaders" TEXT,
"economy_overview" TEXT,
"telephones_mobile_cellular" BIGINT,
"telephones_mobile_cellular_details" TEXT,
"independence" TEXT,
"natural_gas_exports" BIGINT,
"natural_gas_exports_details" TEXT,
"natural_gas_imports" BIGINT,
"natural_gas_imports_details" TEXT,
"natural_gas_consumption" BIGINT,
"natural_gas_consumption_details" TEXT,
"religions" DECIMAL,
"religions_details" TEXT,
"current_account_balance" TEXT,
"current_account_balance_details" TEXT,
"public_debt" UUID,
"public_debt_details" UUID,
"investment_gross_fixed" UUID,
"investment_gross_fixed_details" UUID,
"internet_hosts" UUID,
"internet_hosts_details" UUID,
"reserves_of_foreign_exchange_and_gold" UUID,
"reserves_of_foreign_exchange_and_gold_details" UUID,
"electricity_imports" DECIMAL,
"electricity_imports_details" TEXT,
"urbanization" DECIMAL,
"urbanization_details" TEXT,
"stock_of_domestic_credit" TEXT,
"stock_of_domestic_credit_details" TEXT,
"military_service_age_and_obligation" BIGINT,
"military_service_age_and_obligation_details" UUID,
"manpower_fit_for_military_service" DECIMAL,
"manpower_fit_for_military_service_details" TEXT,
"national_holiday" TEXT,
"merchant_marine" BIGINT,
"merchant_marine_details" BIGINT,
"elevation_extremes" DECIMAL,
"elevation_extremes_details" TEXT,
"natural_hazards" TEXT,
"area_comparative" TEXT,
"literacy" DECIMAL,
"literacy_details" TEXT,
"life_expectancy_at_birth" DECIMAL,
"life_expectancy_at_birth_details" TEXT,
"legislative_branch" TEXT,
"legal_system" TEXT,
"international_organization_participation" TEXT,
"maritime_claims" DECIMAL,
"maritime_claims_details" TEXT,
"manpower_available_for_military_service" DECIMAL,
"manpower_available_for_military_service_details" TEXT,
"military_expenditures" DECIMAL,
"military_expenditures_details" TEXT,
"environment_international_agreements" TEXT,
"environment_current_issues" TEXT,
"airports_with_unpaved_runways" DECIMAL,
"airports_with_unpaved_runways_details" BIGINT,
"airports_with_paved_runways" DECIMAL,
"airports_with_paved_runways_details" BIGINT,
"electricity_production" BIGINT,
"electricity_production_details" TEXT,
"railways" BIGINT,
"railways_details" BIGINT,
"ports_and_terminals" TEXT,
"suffrage" DECIMAL,
"suffrage_details" TEXT,
"industrial_production_growth_rate" DECIMAL,
"industrial_production_growth_rate_details" TEXT,
"terrain" TEXT,
"telephone_system" TEXT,
"total_fertility_rate" DECIMAL,
"total_fertility_rate_details" TEXT,
"unemployment_rate" DECIMAL,
"unemployment_rate_details" TEXT,
"government_type" TEXT,
"flag_description" TEXT,
"illicit_drugs" TEXT,
"imports" TEXT,
"imports_details" TEXT,
"roadways" BIGINT,
"roadways_details" BIGINT,
"population_growth_rate" DECIMAL,
"population_growth_rate_details" TEXT,
"gdp_real_growth_rate" DECIMAL,
"gdp_real_growth_rate_details" TEXT,
"heliports" DECIMAL,
"heliports_details" BIGINT,
"gdp_purchasing_power_parity" TEXT,
"gdp_purchasing_power_parity_details" TEXT,
"diplomatic_representation_from_the_us" TEXT,
"gdp_per_capita_ppp" TEXT,
"gdp_per_capita_ppp_details" TEXT,
"natural_gas_production" BIGINT,
"natural_gas_production_details" TEXT
)
WITH (
OIDS=FALSE
);
-- real 0m5.684s
-- user 0m5.299s
-- sys 0m0.124s
-- csv2psql schema -f sql ./tmp/sfpd_incident_2003.csv
CREATE TABLE my_table(
"incidntnum" BIGINT NOT NULL,
"category" TEXT NOT NULL,
"descript" TEXT NOT NULL,
"dayofweek" TEXT NOT NULL,
"date" TEXT NOT NULL,
"time" TEXT NOT NULL,
"pddistrict" TEXT,
"resolution" TEXT NOT NULL,
"location" TEXT NOT NULL,
"x" DECIMAL NOT NULL,
"y" DECIMAL NOT NULL
)
WITH (
OIDS=FALSE
);
-- real 0m43.123s
-- user 0m42.322s
-- sys 0m0.435s
csv2psql schema -f table ./tmp/sfpd_incident_2014.csv

+------------+----------+----------+
|   ./tmp/sfpd_incident_2014.csv   |
+------------+----------+----------+
| column     | type     | null     |
+------------+----------+----------+
| IncidntNum | bigint   | false    |
| Category   | text     | false    |
| Descript   | text     | false    |
| DayOfWeek  | text     | false    |
| Date       | text     | false    |
| Time       | text     | false    |
| PdDistrict | text     | false    |
| Resolution | text     | false    |
| Location   | text     | false    |
| X          | decimal  | false    |
| Y          | decimal  | false    |
+------------+----------+----------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment