%%fsql cell magic empty dataframe

I have the following import (directory structure hidden because it contains proprietary information).

df = pd.read_csv(f’c:\dir\_with_vars_as_select_date_2022_07_01_as_upg_start_date_2024_06_3_202409051643.csv’)
print(len(df)) gives 3836643 rows
then %%fsql select * from df limit 10
gives
UsageError: %%fsql is a cell magic, but the cell body is empty.

I have installed fugue and entered the code as suggested on the its web site.

I recognize that this is a giant data frame, but I am looking for a needle in a haystack here.

Any help greatly appreciated.

Chris

The code included in your post is nearly unreadable as written here. Can you clearly delineate what is a cell and a second cell, etc.? And actually use formatted code blocks?
For pasting code in so it is readable in forums such as this, you’ll want to learn about ‘block code formatting’ here. (Or see about ‘fenced code blocks’ here. They are both the same thing if you look into the details. They just have slightly different terms used in the two locations.


One thing I see is that you syntax after %%fsql doesn’t look like SQL to me.

Note here they use FROM , SELECT, etc…

And if you look at under ‘Checking Table Schema’ here, you’ll see them point out SELECT * FROM ... in an example SQL call.

Thanks for taking time to read and for your suggestions. In future I will manage code blocks better. As it turns out this is a dumb user error (mine) - I had not placed the %%fsql cell magic tag on its own line… So the problem is solved! I will mark it as resolved.

1 Like