Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly handle data with line breaks #1

Open
loisaidasam opened this issue Aug 21, 2018 · 1 comment
Open

Properly handle data with line breaks #1

loisaidasam opened this issue Aug 21, 2018 · 1 comment

Comments

@loisaidasam
Copy link
Owner

The current implementation borks on data with line breaks, as pointed out by this SO comment:

https://stackoverflow.com/questions/12109622/how-to-know-the-byte-position-of-a-row-of-a-csv-file-in-python/51792959?noredirect=1#comment90828948_51792959

loisaidasam added a commit that referenced this issue Aug 21, 2018
@loisaidasam
Copy link
Owner Author

$ python setup.py test
running test
running egg_info
writing csv_position_reader.egg-info/PKG-INFO
writing top-level names to csv_position_reader.egg-info/top_level.txt
writing dependency_links to csv_position_reader.egg-info/dependency_links.txt
reading manifest file 'csv_position_reader.egg-info/SOURCES.txt'
writing manifest file 'csv_position_reader.egg-info/SOURCES.txt'
running build_ext
test_bad_seek (tests.tests.DictReaderTests) ... ok
test_basic (tests.tests.DictReaderTests) ... ok
test_csv_with_newlines (tests.tests.DictReaderTests) ... FAIL
test_seek (tests.tests.DictReaderTests) ... ok
test_seek_without_setting_header (tests.tests.DictReaderTests) ... ok
test_bad_seek (tests.tests.ReaderTests) ... ok
test_basic (tests.tests.ReaderTests) ... ok
test_csv_with_newlines (tests.tests.ReaderTests) ... FAIL
test_seek (tests.tests.ReaderTests) ... ok

======================================================================
FAIL: test_csv_with_newlines (tests.tests.DictReaderTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "csv-position-reader/tests/tests.py", line 146, in test_csv_with_newlines
    "description": "Speaking of bold, who has the gumption to claim partial credit for the Four Seasons?!\n \n Wow.",
AssertionError: Tuples differ: (177, {'album': 'ANNO: Four Se... != (177, {'album': 'ANNO: Four Se...

First differing element 1:
{'album': 'ANNO: Four Seasons', 'description': 'Speaking of bold, who has the gumption to claim partial credit for the Four Seasons?!\n', 'artist': 'Anna Meredith & Antonio Vivaldi'}
{'album': 'ANNO: Four Seasons', 'description': 'Speaking of bold, who has the gumption to claim partial credit for the Four Seasons?!\n \n Wow.', 'artist': 'Anna Meredith & Antonio Vivaldi'}

  (177,
   {'album': 'ANNO: Four Seasons',
    'artist': 'Anna Meredith & Antonio Vivaldi',
-   'description': 'Speaking of bold, who has the gumption to claim partial credit for the Four Seasons?!\n'})
+   'description': 'Speaking of bold, who has the gumption to claim partial credit for the Four Seasons?!\n \n Wow.'})
?                                                                                                          ++++++++


======================================================================
FAIL: test_csv_with_newlines (tests.tests.ReaderTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "csv-position-reader/tests/tests.py", line 63, in test_csv_with_newlines
    "Speaking of bold, who has the gumption to claim partial credit for the Four Seasons?!\n \n Wow."
AssertionError: Tuples differ: (177, ['Anna Meredith & Antoni... != (177, ['Anna Meredith & Antoni...

First differing element 1:
['Anna Meredith & Antonio Vivaldi', 'ANNO: Four Seasons', 'Speaking of bold, who has the gumption to claim partial credit for the Four Seasons?!\n']
['Anna Meredith & Antonio Vivaldi', 'ANNO: Four Seasons', 'Speaking of bold, who has the gumption to claim partial credit for the Four Seasons?!\n \n Wow.']

  (177,
   ['Anna Meredith & Antonio Vivaldi',
    'ANNO: Four Seasons',
-   'Speaking of bold, who has the gumption to claim partial credit for the Four Seasons?!\n'])
+   'Speaking of bold, who has the gumption to claim partial credit for the Four Seasons?!\n \n Wow.'])
?                                                                                           ++++++++


----------------------------------------------------------------------
Ran 9 tests in 0.012s

FAILED (failures=2)
Test failed: <unittest.runner.TextTestResult run=9 errors=0 failures=2>
error: Test failed: <unittest.runner.TextTestResult run=9 errors=0 failures=2>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant