28 lines
748 B
Python
Executable file
28 lines
748 B
Python
Executable file
#!/usr/bin/env python
|
|
|
|
import requests
|
|
import csv
|
|
import io
|
|
|
|
# Send a GET request to the US Census Bureau dataset URL
|
|
url = "https://www2.census.gov/programs-surveys/popest/datasets/2010-2019/cities/totals/sub-est2019_all.csv"
|
|
response = requests.get(url)
|
|
|
|
# Check if the request was successful
|
|
if response.status_code == 200:
|
|
# Read the CSV content from the response
|
|
csv_content = io.StringIO(response.text)
|
|
|
|
# Create a CSV reader object
|
|
reader = csv.reader(csv_content)
|
|
|
|
# Get the column names from the first row
|
|
column_names = next(reader)
|
|
|
|
# Print the column names
|
|
print("Column names:")
|
|
for column_name in column_names:
|
|
print(column_name)
|
|
else:
|
|
print("Failed to fetch the dataset.")
|