Article
· May 16, 2023 1m read

csvgenpy - Import any CSV into InterSystems IRIS Using Embedded Python!

Hi folks!

Just want to introduce you a new util to import CSV into IRIS - csvgenpy!

Install

USER>zpm "install csvgenpy"

Use:

do ##class(shvarov.csvgenpy.csv).Generate("file or url","table","schema")

Example:

USER>do ##class(shvarov.csvgenpy.csv).Generate("https://raw.githubusercontent.com/datasciencedojo/datasets/master/titanic.csv","titanic","data")

This will create table and class data.titanic in IRIS and will load the data.  you can proof it with:

USER>:sql

[SQL]USER>>select * from data.titanic

[SQL]USER>>select * from data.titanic

1. select * from data.titanic


passengerid survived pclass name sex age sibsp parch ticket fare cabin embarked

1 0 3 Braund, Mr. Owen Harris male 22 1 0 A/5 21171 7.25 S

2 1 1 Cumings, Mrs. John Bradley (Florence Briggs Thayer) female 38 1 0 PC 17599 71.283299999999996998 C85 C

3 1 3 Heikkinen, Miss. Laina female 26 0 0 STON/O2. 3101282 7.9249999999999998223 S

...

So that's it!

Basically it does the same thing as csvgen does, but uses python library sqlalchemy which works because of embedded python and sqlalchemy-iris by @Dmitry Maslennikov 

P.S. csvgenpy can import some "complicated" for csvgen csv as this one. Basically it can import any kind of csv.

Feedback and Pull requests are very welcome!

Discussion (0)1
Log in or sign up to continue