Load CSV Records

Read csv_text with Pandas and return a list of row dictionaries in file order. The first line contains column names. Values are complete strings or finite numbers; let Pandas infer numeric types. Quoted commas and line breaks belong to their field. A header-only CSV returns an empty list. Use StringIO to read the supplied text; no file download is needed.

Difficulty: beginner

Show hint

Wrap csv_text in StringIO, call pd.read_csv, then convert the DataFrame with to_dict(orient="records").

Examples

  • ["name,score\nAsha,82\nBikash,91\n"][{"name":"Asha","score":82},{"name":"Bikash","score":91}]

Your solution

Python · Pandas

Results

Python and Pandas load when you Run or Submit. Return a Python list, dictionary or scalar as requested.

Back to Lesson