Skip to content

Retain leading zeros when converting text or --no-type-inference #83

@fburleigh

Description

@fburleigh

Describe the bug

A clear and concise description of what the bug is.
Value tokens like 0003530043 and 00126 are converted to text without their leading zeros.

Expected behavior

Using CLI option --no-type-inference or --type-hint-header with a column that hints text, then the value 0003530043 should be converted as 0003530043 rather than 3530043.

To Reproduce

Steps to reproduce the behavior:

  1. Given this CSV called zero.csv:
column1, column2-text
123, 0123
0123, 123
123, 0123
  1. And the CLI: sqlitebiter --type-hint-header -o zero.sqlite file zero.csv
  2. Then after sqlite3 zero.sqlite:
.header on;
select * from zero;
  1. I expect you will see:
column1|column2-text
123|123
123|123
123|123
  1. Verify the table's structure:
CREATE TABLE IF NOT EXISTS 'zero'([column1] INTEGER, [column2-text] TEXT);

Environments

Please complete the following information:

  • uname: Darwin the-admiralty 18.7.0 x86_64

  • CPython version: 3.7.5

  • sqlitebiter version: not installed

  • SimpleSQLite version: not installed

  • pytablereader version: not installed

  • Installation Method: brew

Additional context

Add any other context (logs, error output, etc.) about the problem here.
(If it’s long, please paste to https://ghostbin.co/ and insert the link here.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions