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

AttributeError when detecting multi table metadata from a CSV #1507

Closed
Raghuramrwttw opened this issue Jul 18, 2023 · 2 comments
Closed

AttributeError when detecting multi table metadata from a CSV #1507

Raghuramrwttw opened this issue Jul 18, 2023 · 2 comments
Labels
bug Something isn't working feature:metadata Related to describing the dataset

Comments

@Raghuramrwttw
Copy link

im getting error like
AttributeError: 'SingleTableMetadata' object has no attribute '_load_data_from_csv'

this is my code:
metadata.detect_table_from_csv(
table_name='hotels',
filepath='C:/Users/Admin/Desktop/pythonsdv/hotels.csv'
)
and this is the error im getting
AttributeError Traceback (most recent call last)
Cell In[4], line 1
----> 1 metadata.detect_table_from_csv(
2 table_name='hotels',
3 filepath='C:/Users/Admin/Desktop/pythonsdv/hotels.csv'
4 )

File c:\Users\Admin\Desktop\pythonsdv\env\lib\site-packages\sdv\metadata\multi_table.py:357, in MultiTableMetadata.detect_table_from_csv(self, table_name, filepath)
355 self._validate_table_not_detected(table_name)
356 table = SingleTableMetadata()
--> 357 data = table._load_data_from_csv(filepath)
358 print(data)
359 table._detect_columns(data)

AttributeError: 'SingleTableMetadata' object has no attribute '_load_data_from_csv'

please help to get out from this error

@Raghuramrwttw Raghuramrwttw added new Automatic label applied to new issues question General question about the software labels Jul 18, 2023
@npatki
Copy link
Contributor

npatki commented Jul 21, 2023

Hi @Raghuramrwttw thanks for filing this issue. I'm going to classify this as a bug since I'm able to replicate it with the demo data.

Workaround

A simple workaround is to load the data yourself as a pandas dataframe. Then you can use the other function detect_table_from_dataframe.

Note that pandas is already pre-installed when you install SDV.

import pandas as pd

hotels_dataframe = pd.read_csv('C:/Users/Admin/Desktop/pythonsdv/hotels.csv')
metadata.detect_table_from_dataframe(
    table_name='hotels',
    data=hotels_dataframe
)

You can do this independently for each table in your database.

For SDV Developers

Seems like table._load_data_from_csv was left there accidentally. Shouldn't we be using the function from utils instead?

from sdv.utils import load_data_from_csv

It would also be good to add an integration test for this.

@npatki npatki added bug Something isn't working under discussion Issue is currently being discussed and removed question General question about the software new Automatic label applied to new issues labels Jul 21, 2023
@npatki npatki changed the title getting error while working on own dataset to generate multiple data AttributeError when detecting multi table metadata from a CSV Jul 21, 2023
@npatki npatki added feature:metadata Related to describing the dataset and removed under discussion Issue is currently being discussed labels Aug 1, 2023
@amontanez24
Copy link
Contributor

closed by #1533

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working feature:metadata Related to describing the dataset
Projects
None yet
Development

No branches or pull requests

3 participants