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.

Better document that records should be a list/iterable of data dictionaries

See original GitHub issue

As mentioned in https://github.com/fastavro/fastavro/issues/252#issuecomment-407165534, it’s not as clear as it should be that records is an iterable of data dictionaries. If someone provides just a dictionary they get a confusing exception. Perhaps we could also add a small check to make sure data is an acceptable format.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
scottbeldencommented, Apr 13, 2021

@300LiterPropofol Are you trying to use writer or schemaless_writer?

Suppose you have a record like this:

record = {...}

If you are using writer, it expects an iterable of records. An easy way to write a single record would be like this:

writer(fp, schema, [record])  # Notice how the single record dictionary is wrapped in a list

If you are using schemaless_writer, it expects a single record (since it can only be used to encode a single record). Therefore, it is called like this:

schemaless_writer(fp, schema, record)  # Notice how we pass the single dictionary without wrapping it in a list

Does this answer your question?

0reactions
300LiterPropofolcommented, Apr 14, 2021

Thank you very much for your reply! I noticed this difference after re-reading the source code a couple of times. Also I finally found my exception is not essentially caused by schemaless-writer function’s record input format but something’s format inside the record, your explanation is really clear and really helpful. Thank you for being so patient and helpful all way along.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Make a Data Dictionary - OSF Support
The purpose of a data dictionary is to explain what all the variable names and values in your spreadsheet really mean. Variable names;...
Read more >
Data Dictionaries | U.S. Geological Survey - USGS.gov
A data dictionary is used to catalog and communicate the structure and content of data, and provides meaningful descriptions for individually named data...
Read more >
A Quick Guide to Data Dictionary | CMS
A data dictionary1 is a collection of descriptions of data objects or terms, definitions, and properties in a data asset. Data dictionaries ......
Read more >
Data Dictionary: a how to and best practices | by Carl Anderson
First, pull any definitions from any existing documentation. This could be from a wiki, annual reports, or from actual code such as SQL...
Read more >
Best Practices for Describing Your Data: Data Dictionaries
In most cases, you should create your dictionary as a plain text file with an introduction giving basic information about the dataset, followed....
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