sassoftware / sassoftware/python-swat

read_excel can't read datetime values

Open
#116 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
159
Forks
65
PR merge metrics
No merged PRs in 30d

Description

read_excel from SWAT works different that read_excel from Pandas, wich makes me unable to read Date column as a Datetime value.

SWAT: storm_damage = conn.read_excel("D:\Workshop\VIYAPY\storm.xlsx", sheet_name="Storm_Damage", casout=dict(name="STORM_DAMAGE", replace=True, caslib="Public"))
It reads Date column as Varchar

Pandas: sd = pd.read_excel("D:\Workshop\VIYAPY\storm.xlsx", sheet_name="Storm_Damage")
It reads Date column as datetime64

I've tried explicity use converters and it is not helping:

SWAT: storm_damage = conn.read_excel("D:\Workshop\VIYAPY\storm.xlsx", sheet_name="Storm_Damage",
casout=dict(name="STORM_DAMAGE", replace=True, caslib="Public"),
converters={'Date': pd.to_datetime})

Pandas: sd = pd.read_excel("D:\Workshop\VIYAPY\storm.xlsx", sheet_name="Storm_Damage", converters={'Date': pd.to_datetime})

Anything I do I see the action run is:
NOTE: 20: action table.loadTable / path='_f_c15dc565_7ff582b29b88.csv', readAhead=true, importOptions={fileType='csv', vars={Cost={type='double'}, Date={type='varchar'}, Event={type='varchar'}, Summary={type='varchar'}}, locale='EN-us'}, resident=true, promote=false, caslib='_LIB_C15DC565_7FF582B29B88', casOut={name='STORM_DAMAGE', caslib='Public', replace=true}, singlePass=false, noSource=true;

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the conn.read_excel entry point and inspect the logged table.loadTable action, especially the Date variable's varchar type and CSV import options. Reproduce the reported workbook and verify that the Date column is loaded as a datetime value while preserving the existing read_excel behavior for other columns.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.