GenericMappingTools / pygmt

A Python interface for the Generic Mapping Tools.
https://www.pygmt.org
BSD 3-Clause "New" or "Revised" License
758 stars 220 forks source link

Load .csv or .dat file in PyGMT #426

Closed zulfakriza closed 4 years ago

zulfakriza commented 4 years ago

Description of the problem

Hi, I am a new user on PyGMT, before I used GMT 5 to create some map and plotting the EQ data. But in PyGMT I had a bit issue when trying to load data (.csv or .dat) in my map.

Is there any clue how to load .csv or .dat data format in PyGMT?

Thank you

Full code that generated the error

PASTE CODE HERE

Full error message

PASTE ERROR MESSAGE HERE

System information

output of conda list
PASTE OUTPUT OF CONDA LIST HERE
welcome[bot] commented 4 years ago

👋 Thanks for opening your first issue here! Please make sure you filled out the template with as much detail as possible. You might also want to take a look at our contributing guidelines and code of conduct.

weiji14 commented 4 years ago

Hi @zulfakriza,

For .csv files, you can follow the answer outlined at https://forum.generic-mapping-tools.org/t/how-to-load-data-into-pygmt/392, basically by using pandas. I actually made an example using earthquake data before from GNS, New Zealand at https://nbviewer.jupyter.org/github/GenericMappingTools/foss4g2019oceania/blob/master/2_pydata_and_pygmt.ipynb.

As for .dat files, you might need to upload an example as it's quite a generic format. Is it a binary format, ASCII text format, or something else?

zulfakriza commented 4 years ago

Hi @weiji14

Many thanks for your response, then for the .dat file, I mean ASCII text format

Regards

weiji14 commented 4 years ago

If it's just text, then pandas.read_csv should work on that .dat file too. There's options to skip header lines, set column names, etc.

That said, some of the Data Processing functions allow you to pass the filename into PyGMT directly. So it depends on what you want to do :smile:

zulfakriza commented 4 years ago

Hi @weiji14

Thanks a lot, I will try it

Cheers Zulfakriza

seisman commented 4 years ago

Closing the issue. Please post general questions on the GMT Community Forum.