You are not logged in.
Pages: 1
So I am creating a csv file using df.to_csv pandas function.
when I open it using xdg-open it is opening via vscode.
On checking further , via xdg-mime query filetype file.csv it is giving me , text/plain which is set to be opened via vscodium only.
In mimeapps.list text/csv is set to be opened via libreoffice which works if i opens it via nautilus. libreoffice-calc is also set to open csv file by default in nautilus.
any idea how to make xdg-open recognise csv file as csv instead of plain text using arch/sway if it is relevant
Offline
Do you have shared-mime-info installed?
If so, check /usr/share/mime/text/csv.xml is present (it is not part of the package, but should be autogenerated upon installation).
Last edited by Hanabishi (2023-11-09 12:50:53)
Offline
yes it is installed and file exists as well
<?xml version="1.0" encoding="utf-8"?>
<mime-type xmlns="http://www.freedesktop.org/standards/shared-mime-info" type="text/csv">
<!--Created automatically by update-mime-database. DO NOT EDIT!-->
<comment>CSV document</comment>
<comment xml:lang="zh_TW">CSV 文件</comment>
<comment xml:lang="zh_CN">CSV 文档</comment>
<comment xml:lang="vi">Tài liệu CSV</comment>
<comment xml:lang="uk">документ CSV</comment>
<comment xml:lang="tr">CSV belgesi</comment>
<comment xml:lang="sv">CSV-dokument</comment>
<comment xml:lang="sr">ЦСВ документ</comment>
<comment xml:lang="sq">dokument CSV</comment>
<comment xml:lang="sl">Dokument CSV</comment>
<comment xml:lang="si">CSV ලේඛනය</comment>
<comment xml:lang="sk">Dokument CSV</comment>
<comment xml:lang="ru">Документ CSV</comment>
<comment xml:lang="ro">Document CSV</comment>
<comment xml:lang="pt_BR">Documento CSV</comment>
<comment xml:lang="pt">documento CSV</comment>
<comment xml:lang="pl">Dokument CSV</comment>
<comment xml:lang="oc">document CSV</comment>
<comment xml:lang="nn">CSV-dokument</comment>
<comment xml:lang="nl">CSV-document</comment>
<comment xml:lang="nb">CSV-dokument</comment>
<comment xml:lang="lv">CSV dokuments</comment>
<comment xml:lang="lt">CSV dokumentas</comment>
<comment xml:lang="ko">CSV 문서</comment>
<comment xml:lang="kk">CSV құжаты</comment>
<comment xml:lang="ka">CSV დოკუმენტი</comment>
<comment xml:lang="ja">CSV ドキュメント</comment>
<comment xml:lang="it">Documento CSV</comment>
<comment xml:lang="is">CSV skjal</comment>
<comment xml:lang="id">Dokumen CSV</comment>
<comment xml:lang="ia">Documento CSV</comment>
<comment xml:lang="hu">CSV dokumentum</comment>
<comment xml:lang="hr">CSV dokument</comment>
<comment xml:lang="he">מסמך CSV</comment>
<comment xml:lang="gl">documento CSV</comment>
<comment xml:lang="ga">cáipéis CSV</comment>
<comment xml:lang="fur">document CSV</comment>
<comment xml:lang="fr">document CSV</comment>
<comment xml:lang="fo">CSV skjal</comment>
<comment xml:lang="fi">CSV-asiakirja</comment>
<comment xml:lang="eu">CSV dokumentua</comment>
<comment xml:lang="es">documento CSV</comment>
<comment xml:lang="eo">CSV-dokumento</comment>
<comment xml:lang="en_GB">CSV document</comment>
<comment xml:lang="el">Έγγραφο CSV</comment>
<comment xml:lang="de">CSV-Dokument</comment>
<comment xml:lang="da">CSV-dokument</comment>
<comment xml:lang="cs">dokument CSV</comment>
<comment xml:lang="ca">document CSV</comment>
<comment xml:lang="bg">Документ — CSV</comment>
<comment xml:lang="be@latin">Dakument CSV</comment>
<comment xml:lang="be">дакумент CSV</comment>
<comment xml:lang="ast">Documentu CVS</comment>
<comment xml:lang="ar">مستند CSV</comment>
<comment xml:lang="af">CSV-dokument</comment>
<acronym>CSV</acronym>
<expanded-acronym>Comma Separated Values</expanded-acronym>
<alias type="text/x-comma-separated-values"/>
<alias type="text/x-csv"/>
<sub-class-of type="text/plain"/>
<glob pattern="*.csv"/>
</mime-type>Offline
another thing is that if i open file via libreoffice, and save it without doing any modification, now the output of
xdg-mime query filetype file.csv is text/csv instead
Last edited by jerryDaBaaws (2023-11-09 14:35:41)
Offline
For me even completely empty (0 bytes) file gives the right mime type.
$ file file.csv
file.csv: empty
$ xdg-mime query filetype file.csv
text/csvAfaik there is no magic value to identify csv by content. So it is only about the file extension.
Offline
but in my case xdg-mime query is giving 2 separate values for 2 files with .csv extension.
libreoffice-calc has to be adding some extra metadata while saving file as csv
Offline
◉ touch /tmp/foo.csv
◉ xdg-mime query filetype /tmp/foo.csv
inode/x-emptyEven adding some CSB (text/plain) or explcitly adding *.csv to ~/.local/share/mime/globs and running "update-mime-database ~/.local/share/mime" didn't change anything about that.
@jerryDaBaaws can you upload the files (or functionally equivalent dummies)?
Offline
https://file.io/FargAL49ETKz
sure , here you go
Offline
Deleted
The transfer you requested has been deleted.
Offline
my bad, uploaded them again
https://file.io/JrhcKTb1uIdZ
Offline
The significant difference would be the trailing newline, though both are still text/plain here (not that I particuarily care, just to mention)
Offline
> both are still text/plain here
on my system, one is text/plain. other is text/csv
and also i dont think newline should matter in context of mimetype
Offline
Did you test whether you can control the type w/ the trailing newline?
and also i dont think newline should matter in context of mimetype
Yes "should" …
Offline
Pages: 1