Skip to content

Commit

Permalink
+types nextrecord.copy()
Browse files Browse the repository at this point in the history
  • Loading branch information
gdraheim committed Jul 30, 2024
1 parent 6be11f0 commit c23eae4
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions tabxlsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -1044,29 +1044,29 @@ def extension(filename: str) -> Optional[str]:
import csv
reader = csv.DictReader(inp, delimiter=tab)
for nextrecord in reader:
record: Dict[str, CellValue] = nextrecord.copy()
data.append(record)
newrecord: Dict[str, CellValue] = nextrecord.copy()
data.append(newrecord)
for nam, val in nextrecord.items():
if val.strip() == none_string:
record[nam] = None
newrecord[nam] = None
elif val.strip() == false_string:
record[nam] = False
newrecord[nam] = False
elif val.strip() == true_string:
record[nam] = True
newrecord[nam] = True
else:
try:
record[nam] = int(val)
newrecord[nam] = int(val)
except:
try:
record[nam] = float(val)
newrecord[nam] = float(val)
except:
try:
record[nam] = Time.strptime("%Y-%m%d.%H%M", val)
newrecord[nam] = Time.strptime("%Y-%m%d.%H%M", val)
except:
try:
record[nam] = Time.strptime("%Y-%m%d", val).date()
newrecord[nam] = Time.strptime("%Y-%m%d", val).date()
except:
record[nam] = val.strip()
newrecord[nam] = val.strip()
return TabText(data, list(reader.fieldnames if reader.fieldnames else []))
# must have headers
lookingfor = "headers"
Expand Down

0 comments on commit c23eae4

Please sign in to comment.