question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ecsv files fail to write with units in metadata

See original GitHub issue

This code fails because of the units in the metadata:

from astropy import table, units as u
t = table.Table()
t.meta = {"foo": 5*u.km, "foo2": u.s}
t["bar"] = [7]*u.km
t.write("test.dat", format="ascii.ecsv")

Note that either a quantity or a unit will cause the failure.

This is the end of the error messages I’m getting:

~/anaconda3/envs/py2/lib/python2.7/site-packages/yaml/representer.pyc in represent_object(self, data)
    408             reduce = copy_reg.dispatch_table[cls](data)
    409         elif hasattr(data, '__reduce_ex__'):
--> 410             reduce = data.__reduce_ex__(2)
    411         elif hasattr(data, '__reduce__'):
    412             reduce = data.__reduce__()

~/anaconda3/envs/py2/lib/python2.7/copy_reg.pyc in _reduce_ex(self, proto)
     68     else:
     69         if base is self.__class__:
---> 70             raise TypeError, "can't pickle %s objects" % base.__name__
     71         state = base(self)
     72     args = (self.__class__, base, state)

TypeError: can't pickle int objects

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
taldcroftcommented, Dec 14, 2016

OK, I snuck away long enough to make #5605.

0reactions
taldcroftcommented, Dec 14, 2016

I likely won’t have time today (niece’s graduation, full day with family), but it would be great if someone could drive this home for 1.3 as a bug fix (otherwise 1.3.1). Basically just need a test writing and reading back a single ECSV table that has a unit, quantity, skycoord, and time object in the meta. I believe this is sufficient due to solid coverage for the base machinery of ECSV and YAML serialization.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ECSV Format — Astropy v5.2
The format stores column specifications like unit and data type along with table metadata by using a YAML header data structure. The actual...
Read more >
ECSV
If you follow this pattern, it's possible to write your own ECSV files by taking ... that gives column datatypes, and possibly other...
Read more >
Status of ECSV? - Google Groups
a CSV file with some metadata attached to it. ... they're using Pandas to read and write these files, so ... unit: !astropy.units....
Read more >
Error in parsing CSV load file · Issue #376 · dimitri/pgloader
I am getting the below error while parsing the load file written for CSV ... LOAD CSV FROM '/home/ubuntu/Postgresql/input/metadata.csv' INTO ...
Read more >
2.3 More challenging csv and delimited files | Data Wrangling ...
1.1 Meta data in data files. Data files may have rows at the beginning, and sometimes the end, that are not data or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found