Add csv parser
This commit is contained in:
parent
8f31f6ff84
commit
cbc1c08350
|
@ -30,8 +30,8 @@ db = create_connection()
|
|||
|
||||
class Glacier(db.Model):
|
||||
uid = db.Column(db.Integer, primary_key=True)
|
||||
country = db.Column(db.String(30))
|
||||
name = db.Column(db.String(30))
|
||||
country = db.Column(db.String(60))
|
||||
name = db.Column(db.String(60))
|
||||
|
||||
def __init__(self, uid, country, name):
|
||||
self.uid = uid
|
||||
|
@ -73,7 +73,7 @@ class Annual_Change(db.Model):
|
|||
self.year = year
|
||||
|
||||
|
||||
class Users(db.Model):
|
||||
class User(db.Model):
|
||||
uid = db.Column(db.Integer, primary_key=True)
|
||||
registration_date = db.Column(db.DateTime, nullable=False)
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from pandas import read_csv, concat, DataFrame
|
||||
from iso3166 import countries as co
|
||||
from pandas import DataFrame, concat, read_csv
|
||||
from csv import QUOTE_NONNUMERIC
|
||||
|
||||
|
||||
def country_conversion(political_unit) -> str:
|
||||
|
@ -15,16 +16,26 @@ def select_columns() -> DataFrame:
|
|||
"YEAR",
|
||||
"AREA_SURVEY_YEAR",
|
||||
"AREA_CHANGE",
|
||||
"THICKNESS CHANGE",
|
||||
"THICKNESS_CHG",
|
||||
"VOLUME_CHANGE",
|
||||
]
|
||||
iter_csv = read_csv(
|
||||
"../../data/WGMS-FoG-2019-12-D-CHANGE.csv",
|
||||
"../data/WGMS-FoG-2019-12-D-CHANGE.csv",
|
||||
skipinitialspace=True,
|
||||
usecols=fields,
|
||||
iterator=True,
|
||||
chunksize=100,
|
||||
converters={"YEAR": country_conversion},
|
||||
converters={"POLITICAL_UNIT": country_conversion},
|
||||
)
|
||||
data = concat([chunk[chunk["YEAR"] > min_year] for chunk in iter_csv])
|
||||
return data
|
||||
|
||||
|
||||
def main():
|
||||
df = select_columns()
|
||||
database = "../data/igdb.csv"
|
||||
df.to_csv(database, index=False, quoting=QUOTE_NONNUMERIC)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -18,7 +18,7 @@ datos relevantes para estudios acerca del cambio climático, y acotando éstos a
|
|||
*** Datos
|
||||
|
||||
1. *RD1*: Datos del glaciar
|
||||
- País - /Cadena de 30 caracteres máximo/
|
||||
- País - /Cadena de 60 caracteres máximo/
|
||||
- Nombre del glaciar - /Cadena de 60 caracteres máximo/
|
||||
- ID del glaciar (Compatible con la WGMS) - /Entero de 5 dígitos/
|
||||
|
||||
|
|
Loading…
Reference in New Issue