Skip to content
Snippets Groups Projects
Commit e15a9f4b authored by jvfpw18's avatar jvfpw18
Browse files

Use pandas to read header

parent 9c2293b4
No related branches found
No related tags found
2 merge requests!13v1.1.0,!12Use pandas to read header
...@@ -28,6 +28,7 @@ from database.database_table import gen_data_table, copy_tabbed_to_csv ...@@ -28,6 +28,7 @@ from database.database_table import gen_data_table, copy_tabbed_to_csv
import database.groups import database.groups
import settings import settings
from database.groups import DATA_GROUP, DATABASE_TABLE_NAME from database.groups import DATA_GROUP, DATABASE_TABLE_NAME
import pandas as pd
ENGINE = create_engine(settings.DATABASE_URI, echo=settings.ECHO) ENGINE = create_engine(settings.DATABASE_URI, echo=settings.ECHO)
META = MetaData(bind=ENGINE) META = MetaData(bind=ENGINE)
...@@ -44,8 +45,8 @@ sqlalchemy_logger.setLevel(settings.LOGGING_LEVEL) ...@@ -44,8 +45,8 @@ sqlalchemy_logger.setLevel(settings.LOGGING_LEVEL)
def temporary_data(connection, file_name, table, year, offset=2, def temporary_data(connection, file_name, table, year, offset=2,
delimiters=[';', '\\n', '"'], null=''): delimiters=[';', '\\n', '"'], null=''):
header = open(file_name, encoding="ISO-8859-9").readline().strip() header = pd.read_csv(file_name, encoding="ISO-8859-9", sep=delimiters[0])
header = header.split(delimiters[0]) header = [h.strip() for h in header.columns.values]
ttable = table.get_temporary(header, year) ttable = table.get_temporary(header, year)
ttable.create(bind=connection) ttable.create(bind=connection)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment