Skip to content

Commit

Permalink
Fix retrieving first line
Browse files Browse the repository at this point in the history
  • Loading branch information
caufieldjh committed May 14, 2024
1 parent 569bf52 commit 4e84435
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/clive/loaders/sssom_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,18 @@ def load_map_gsheet(sheet_url: str) -> MappingSetDataFrame:

# Load table from its HTML
sheet_df = pd.read_csv(export_url)
firstline = sheet_df.columns[0]

temp_table_path = Path(TEMP_DIR) / f"{sheet_id}.tsv"
temp_table_write_path = Path(TEMP_DIR) / f"{sheet_id}.tsv.temp"

# Save a local copy to the temp file
sheet_df.to_csv(temp_table_path, sep="\t", index=False, header=False, quoting = csv.QUOTE_NONE)
sheet_df.to_csv(temp_table_path, sep="\t", index=False, header=None, quoting = csv.QUOTE_NONE)

# Clean up the header
with open(temp_table_path, "r") as f:
with open(temp_table_write_path, "w") as f2:
f2.write(firstline + "\n")
for line in f:
if line.startswith("#"):
f2.write(line.rstrip() + "\n")
Expand Down

0 comments on commit 4e84435

Please sign in to comment.