This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pt12lol
Recipients pt12lol
Date 2021-07-20.07:36:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1626766583.9.0.796790901287.issue44677@roundup.psfhosted.org>
In-reply-to
Content
Test sample:

```
import csv
from io import StringIO


def csv_text():
    return StringIO("a|b\nc| 'd\ne|' f")


with csv_text() as input_file:
    print('The following text is going to be parsed:')
    print(input_file.read())
    print()


with csv_text() as input_file:
    dialect_params = [
        'delimiter',
        'quotechar',
        'escapechar',
        'lineterminator',
        'quoting',
        'doublequote',
        'skipinitialspace'
    ]
    dialect = csv.Sniffer().sniff(input_file.read())
    print('The following dialect has been detected:')
    for dialect_param in dialect_params:
        print(f'- {dialect_param}: {repr(getattr(dialect, dialect_param))}')
    print()


with csv_text() as input_file:
    print('Parsed csv text:')
    for entry in csv.reader(input_file, dialect=dialect):
        print(f'- {entry}')
    print()
```

Actual output:

```
The following text is going to be parsed:
a|b
c| 'd
e|' f

The following dialect has been detected:
- delimiter: ' '
- quotechar: "'"
- escapechar: None
- lineterminator: '\r\n'
- quoting: 0
- doublequote: False
- skipinitialspace: False

Parsed csv text:
- ['a|b']
- ['c|', 'd\ne|', 'f']

```

Expected output:

```
The following text is going to be parsed:
a|b
c| 'd
e|' f

The following dialect has been detected:
- delimiter: '|'
- quotechar: '"'
- escapechar: None
- lineterminator: '\r\n'
- quoting: 0
- doublequote: False
- skipinitialspace: False

Parsed csv text:
- ['a', 'b']
- ['c', " 'd"]
- ['e', "' f"]

```
History
Date User Action Args
2021-07-20 07:36:23pt12lolsetrecipients: + pt12lol
2021-07-20 07:36:23pt12lolsetmessageid: <1626766583.9.0.796790901287.issue44677@roundup.psfhosted.org>
2021-07-20 07:36:23pt12lollinkissue44677 messages
2021-07-20 07:36:23pt12lolcreate