{
"id":1,
"words":["data","base"]
}
My file would be as:
id
words.0
Is there any way we can rename the header of the exported CSV file
Hi Anand,
If you’re asking whether you could rename the headers field name while exporting using mongoexport
,
currently (MongoDB v3.4.x) there is no such feature to do so.
Depending on your use case and if you’re using MongoDB v3.4.x, you could create a read-only Views of the collection. As Views are created using MongoDB Aggregation Pipeline, you could utilise $project to rename your field(s) or apply other document transformations.
Alternatively, as the CSV header is normally the first line of the file, you may be able to utilise other command line tools to replace the first line after the export. For example using sed sed '1 s/words.0/first_word/' example.csv
Regards,
Wan.