You are not logged in.

#1 2016-06-01 09:14:01

Kotrfa
Member
Registered: 2012-10-25
Posts: 213

mime type of CSV files recognised as text/plain

Hello,

I have very simple problem which is driving me crazy for several hours. xdg doesn't recognize csv files as text/csv or comma separated, but instead thinks it is plain text file:

$ xdg-mime query filetype load/out.csv
text/plain

hence, setting appropriate desktop file in mimeapp.list doesn't help, since it is not recognised correctly in the first place. What is more confusing is the fact that when I open it through spacefm, it works as expected (on double click open it in libreoffice-calc).

Does anyone know how to solve this issue?

Thanks

Offline

#2 2016-06-01 09:32:54

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,433

Re: mime type of CSV files recognised as text/plain

text/x-csv is subtype of text/plain, look into the following file if it exist on your system,

"/usr/share/mime/text/csv.xml"

you may define default app for text/x-csv type in .local/share/applications/mimeapps.list

Offline

#3 2016-06-01 10:40:05

Kotrfa
Member
Registered: 2012-10-25
Posts: 213

Re: mime type of CSV files recognised as text/plain

I do:

$ cat /usr/share/mime/text/csv.xml
<?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="ar">مستند CSV</comment>
  <comment xml:lang="be@latin">Dakument CSV</comment>
  <comment xml:lang="bg">Документ — CSV</comment>
  <comment xml:lang="ca">document CSV</comment>
  <comment xml:lang="cs">dokument CSV</comment>
  <comment xml:lang="da">CSV-dokument</comment>
  <comment xml:lang="de">CSV-Dokument</comment>
  <comment xml:lang="el">Έγγραφο CSV</comment>
  <comment xml:lang="en_GB">CSV document</comment>
  <comment xml:lang="eo">CSV-dokumento</comment>
  <comment xml:lang="es">documento CSV</comment>
  <comment xml:lang="eu">CSV dokumentua</comment>
  <comment xml:lang="fi">CSV-asiakirja</comment>
  <comment xml:lang="fo">CSV skjal</comment>
  <comment xml:lang="fr">document CSV</comment>
  <comment xml:lang="ga">cáipéis CSV</comment>
  <comment xml:lang="gl">documento CSV</comment>
  <comment xml:lang="he">מסמך CSV</comment>
  <comment xml:lang="hr">CSV dokument</comment>
  <comment xml:lang="hu">CSV dokumentum</comment>
  <comment xml:lang="ia">Documento CSV</comment>
  <comment xml:lang="id">Dokumen CSV</comment>
  <comment xml:lang="it">Documento CSV</comment>
  <comment xml:lang="ja">CSV ドキュメント</comment>
  <comment xml:lang="ka">CSV დოკუმენტი</comment>
  <comment xml:lang="kk">CSV құжаты</comment>
  <comment xml:lang="ko">CSV 문서</comment>
  <comment xml:lang="lt">CSV dokumentas</comment>
  <comment xml:lang="lv">CSV dokuments</comment>
  <comment xml:lang="nb">CSV-dokument</comment>
  <comment xml:lang="nl">CSV-document</comment>
  <comment xml:lang="nn">CSV-dokument</comment>
  <comment xml:lang="pl">Dokument CSV</comment>
  <comment xml:lang="pt_BR">Documento CSV</comment>
  <comment xml:lang="ro">Document CSV</comment>
  <comment xml:lang="ru">документ CSV</comment>
  <comment xml:lang="sk">Dokument CSV</comment>
  <comment xml:lang="sl">Dokument CSV</comment>
  <comment xml:lang="sq">Dokument CSV</comment>
  <comment xml:lang="sr">ЦСВ документ</comment>
  <comment xml:lang="sv">CSV-dokument</comment>
  <comment xml:lang="tr">CSV belgesi</comment>
  <comment xml:lang="uk">документ CSV</comment>
  <comment xml:lang="vi">Tài liệu CSV</comment>
  <comment xml:lang="zh_CN">CSV 文档</comment>
  <comment xml:lang="zh_TW">CSV 文件</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>

as well as this "text/x-csv=libreoffice-calc.desktop" in .config/mimeapps.list (which is, according to wiki, recommended):

$ cat .config/mimeapps.list
[Added Associations]
application/pdf=zathura.desktop;okular.desktop;chromium.desktop;gimp.desktop;
application/x-bzip-compressed-tar=7zFM.desktop;
audio/flac=vlc.desktop;
audio/mpeg=vlc.desktop;
image/jpeg=kde4-gwenview.desktop;ristretto.desktop;
text/html=kate-2.desktop;kde4-kate.desktop;chromium.desktop;kde4-kfmclient_html.desktop;firefox.desktop;libreoffice-writer.desktop;
video/mp4=vlc.desktop;
text/plain=gedit.desktop;geany.desktop;
image/vnd.djvu=zathura.desktop;
application/vnd.oasis.opendocument.text=juffed.desktop;openoffice4-writer.desktop;
image/png=ristretto.desktop;
text/x-c++src=filezilla.desktop;geany.desktop;
image/tiff=ristretto.desktop;
video/x-matroska=parole.desktop;

[Default Applications]
text/plain=geany.desktop
image/jpeg=ristretto.desktop
image/vnd.djvu=zathura.desktop
application/vnd.oasis.opendocument.text=openoffice4-writer.desktop
image/png=ristretto.desktop
text/x-c++src=geany.desktop
image/tiff=ristretto.desktop
video/x-matroska=parole.desktop
x-scheme-handler/https=browser.desktop
x-scheme-handler/http=browser.desktop
text/html=browser.desktop
application/msword=lowriter.desktop
text/csv=libreoffice-calc.desktop
text/x-csv=libreoffice-calc.desktop

Offline

#4 2016-06-01 10:59:41

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,433

Re: mime type of CSV files recognised as text/plain

if it opens correctly with spacefm, where does it fail or how do you intend to open your csv file?

Offline

#5 2016-06-01 12:51:27

Kotrfa
Member
Registered: 2012-10-25
Posts: 213

Re: mime type of CSV files recognised as text/plain

Chromium use xdg-open. When I download CSV, I would like to have it open in libreoffice calc. But when I click on it again in downloaded files (still in chromium), it just get downloaded one more time. That is annoying. Chromium should use xdg-open, hence I'm trying to fix it. When I use "xdg-open somefile.csv" in terminal, I get it open in chromium.

I am using ranger as a main file manager, which has different configuration for opening files (hence I am not bothered by that there). I use spacefm very sparingly, but can see that it is behaving as it should (but don't know why, it probably doesn't use xdg-open)...

Last edited by Kotrfa (2016-06-06 09:41:58)

Offline

#6 2017-01-17 23:00:48

mbosecke
Member
Registered: 2017-01-17
Posts: 1

Re: mime type of CSV files recognised as text/plain

I had the exact same problem and it turns out it was because I wasn't using a typical Desktop Environment, but was instead using the i3 tiling manager. Apparently, xdg-mime is a perl script that detects which common desktop environment you are using and then delegates it's responsibility to an application provided by your desktop environment. If it doesn't find a known desktop environment, it defaults to a command called "mimeinfo" or "file", whichever is available. In my case, it used "file" which is completely unaware of the shared mime database and instead relies on "magic codes" existing within the file which isn't always reliable (especially in the case of CSV files). I installed "mimeinfo" which comes from the EPEL perl-file-mimeinfo package and it worked again; "mimeinfo" apparently uses the shared mime database.

Offline

#7 2017-01-18 07:41:33

Kotrfa
Member
Registered: 2012-10-25
Posts: 213

Re: mime type of CSV files recognised as text/plain

Thanks! I am using i3 as well. This is important observation - couldn't you please document this on arch wiki?

Offline

Board footer

Powered by FluxBB