How to load a CSV file from the Mayavi GUI?

烂漫一生 提交于 2020-01-11 06:49:32

问题


I know how to read the CSV into numpy and do it from a Python script, and that is good enough for my use case.

But since it has a GUI with data loading functionality, I was expecting it would just work for such an universal data format.

So I tried to go on the menu:

  • File
  • Load data
  • Open file

but when I select a simple CSV file:

i=0; while [ "$i" -lt 10 ]; do echo "$i,$((2*i)),$((4*i))"; i=$((i+1)); done > main.csv

which contains:

0,0,0
1,2,4
2,4,8
3,6,12
4,8,16
5,10,20
6,12,24
7,14,28
8,16,32
9,18,36

an error popup shows on the GUI:

No suitable reader found for file /home/ciro/main.csv

Google led me to this interesting file in the source tree: https://github.com/enthought/mayavi/blob/e2569be1096be3deecb15f8fa8581a3ae3fb77d3/mayavi/tools/data_wizards/csv_loader.py but that just looks like an example of how to do it from a script.

Tested in Mayavi 4.6.2.


回答1:


From the documentation

One needs to have some data or the other loaded before a Module or Filter may be used. Mayavi supports several data file formats most notably VTK data file formats. Alternatively, mlab can be used to load data from numpy arrays. For advanced information on data structures, refer to the Data representation in Mayavi section.

I've tested importing using the GUI on a Asus Laptop Intel CoreTM i7-4510U CPU @ 2.00 GHz with 8 GBs de RAM, using Windows 10, both in and out of a Python virtualenv and always got the same problem:

It all points to CSV files not being directly supported, so had to find another workaround.

My favorite was to use a virtual environment and install on it mayavi, jupyterlab, PyQt5 and Pandas.

Then, using PowerShell, start a Jupyter notebook (jupyter notebook) > Upload > Select the .csv. This imported a 1,25 GBs (153543233 rows x 3 columns) .csv in around 20s, which then became available for usage.



来源:https://stackoverflow.com/questions/55949572/how-to-load-a-csv-file-from-the-mayavi-gui

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!