Skip to main content

Elastic CSV Loader

This command line utility loads csv file into an elasticsearch index, using a provided yaml config file.

load-csv considerations:

  • CSV files MUST include a header with field names
  • Header field names will be used as elastic index fields
  • A @timestamp and date fields will be added to all indexed docs
    • A date logic date could be forced through command parameter.
  • Depending on elastic_index.data_format.parent_data_object value, all original csv header fields will be arranged under a data parent object.

Indexed data will use the same field names that

download-index considerations:

  • If csv file is an existing file the download process will append data including headers
  • You have to rename or delete previous csv file if you want to start fresh.

Install

Dependencies

  • Python 3.9 or higher
  • pip package manager
pip install --upgrade elasticcsv

Run

Elastic Connection Config

Connection configuration is based in a YAML text file (connection.yaml) that must be present in command directory.

Sample connection.yaml

elastic_connection:
  proxies:
    http: "http://user:pass@proxy.url:8080"
    https: "http://user:pass@proxy.url:8080"
  user: myuser
  password: mypassword
  apikey_id: myapikey  # apikeys auth takes precedence over user/password
  apikey_secret: myapikeysecret
  node: my.elastic.node
  schema: https
  port: 443
elastic_index:
  data_format:
    parent_data_object: true

Run command

❯ csv2es load-csv --help
Usage: csv2es load-csv [OPTIONS]

  Loads csv to elastic index

Options:
  --csv PATH               CSV File  [required]
  --csv_offset INT         CSV File offset
  --sep TEXT               CSV field sepator  [required]
  --index TEXT             Elastic Index  [required]
  --csv-date-format TEXT   date format for *_date columns as for ex:
                           '%Y-%m-%d'
  --logic_date [%Y-%m-%d]  Date reference for interfaces
  -d, --delete-if-exists   Flag for deleting index before running load
  --help                   Show this message and exit.

Python date formats references: String Format Time

❯ csv2es download-index --help
Usage: csv2es download-index [OPTIONS]

  Download index to csv file

Options:
  --csv PATH              CSV File  [required]
  --sep TEXT              CSV field sepator  [required]
  --index TEXT            Elastic Index  [required]
  -d, --delete-if-exists  Flag for deleting csv file before download
  --help                  Show this message and exit.

Example:

csv2es load-csv --csv ./pathtomyfile/file.csv --index myindex --sep ";"

csv2es download-index --csv ./pathtomyfile/file.csv --index myindex --sep ";" -d

Metadata

Release files for elasticcsv 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for elasticcsv 0.4.1
File Interpreter ABI Platform
elasticcsv-0.4.1-py3-none-any.whl Python 3 none any Details

Release files / elasticcsv-0.4.1-py3-none-any.whl

Download URL elasticcsv-0.4.1-py3-none-any.whl
Size 12.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dfc4be269acea15ed951c640f79d0a8a053216db43e37ebe16e6c13010505202
BLAKE2b-256 checksum
How to use checksums
ce1c49ce442d843de57799ea18ab4fe70e5bdffa51d5260b04e3c0ec2bb7ac56
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.6.4

Release history Release notifications | RSS feed

This release

0.4.1 This release

1 release file

0.3.3

1 release file

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page