# Update old data from csv python

**URL:** https://discuss.elastic.co/t/update-old-data-from-csv-python/297034
**Category:** Elasticsearch
**Created:** [February 12, 2022, 3:30am UTC](https://discuss.elastic.co/t/update-old-data-from-csv-python/297034 "2022-02-12T03:30:21Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![aminedakhlii](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aminedakhlii/32/101752_2.png) [@aminedakhlii](https://discuss.elastic.co/u/aminedakhlii)
#### Post date: [February 12, 2022, 3:30am UTC](https://discuss.elastic.co/t/update-old-data-from-csv-python/297034/1 "2022-02-12T03:30:21Z")

</div>

I have a bunch of indices A,B,C,D containing large amounts of data per each let's say 50 million records per index and the record contains data as follows:

```auto
 user: amine, age: 22, state: Michigan

```

and I want to create a new index E and bulk new data into it from a csv file. What I hope for is that if a user from E already exists in one of the other indices but with different information for example:

```auto
  user: amine, age: 25, state: California 

```

I want the user amine to be updated in all other indices with the new data.

---

<div class="post-metadata">

### Author: ![Tomo\_M](https://avatars.discourse-cdn.com/v4/letter/t/848f3c/32.png) [@Tomo\_M](https://discuss.elastic.co/u/Tomo_M)
#### Post date: [February 12, 2022, 7:48am UTC](https://discuss.elastic.co/t/update-old-data-from-csv-python/297034/2 "2022-02-12T07:48:09Z")

</div>

Create [index alias](https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html) for all indices with writing index targetting E. [Update by query](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html) , with `query` identifying the document of the user and `doc as upsert` parameter, will update the document if exists and create a new document to E if not exists.

You may consider using data stream if you have such situations some times.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [March 12, 2022, 7:48am UTC](https://discuss.elastic.co/t/update-old-data-from-csv-python/297034/3 "2022-03-12T07:48:37Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
