Fonts & Character Setsdatatool + custom separator + french

Information and discussion about fonts and character sets (e.g. how to use language specific characters)
Post Reply
davidonlaptop
Posts: 6
Joined: Sat Apr 03, 2010 9:45 am

datatool + custom separator + french

Post by davidonlaptop »

Hi!

There is an issue while using the datatool package (to import from CSV) along with the babel (french) package and the command \DTLsetseparator.

If not using the babel package, the problem disappear but all text is in english.

If not using the \DTLsetseparator it works, but we can't use comma in the .CSV file.

Below is my latex source code, input CSV, and error output :

Code: Select all

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{datatool}
\usepackage[utf8x]{inputenc}
%\usepackage[francais]{babel}  % this package also causes problem
\usepackage[frenchb]{babel}

\begin{document}

\DTLsetseparator{;}            % this is where the trouble comes from
\DTLloaddb{data}{datatools3.csv}

\begin{tabular}{llrrr}
  \bfseries Besoin &
  \bfseries Priorité &
  \bfseries Préoccupations &
  \bfseries Solution actuelle &
  \bfseries Solution proposée

  \DTLforeach{data}{\besoin=Besoin, \priority=Priorite, \preoccupation=Preoccupations, 
  \currentsolution=Solution actuelle, \newsolution=Solution proposee}{
    \\
    \besoin & \priority & \preoccupation & \currentsolution & \newsolution
  }
\end{tabular}
\end{document}

Code: Select all

Besoin;Priorite;Preoccupations;Solution actuelle;Solution proposee
John;"Smith, Jr";102689;68;68
Jane;Brown;102647;75;68
Andy;Brown;103569;42;68
Zoe;Adams;105987;52;68
Roger;Brady;106872;58;68
Clare;Verdon;104356;45;68

Code: Select all

(/usr/share/texmf/tex/generic/babel/frenchb.cfg))) (./datatool3.aux)
(/usr/share/texmf/tex/latex/lm/t1lmr.fd)
(/usr/share/texmf/tex/latex/ucs/ucsencs.def)
! Use of \@dtl@lopoff doesn't match its definition.
\@dtl@lin@ ->;
              Besoin;Priorite;Preoccupations;Solution actuelle;Solution prop...
l.11 \DTLloaddb{data}{datatools3.csv}
                                     
! Missing $ inserted.
<inserted text> 
                $
l.11 \DTLloaddb{data}{datatools3.csv}
                                     
! Undefined control sequence.
\iterate ...f \@dtl@lin@ \to \@dtl@lin@ \@dtl@key 
                                                  \advance \dtl@entrycr by 1...
l.11 \DTLloaddb{data}{datatools3.csv}
                                     
! Undefined control sequence.
\iterate ...er \@dtl@toks \expandafter {\@dtl@key 
                                                  }\@ifundefined {@dtl@inky@...
l.11 \DTLloaddb{data}{datatools3.csv}
                                     
! Use of \@dtl@lopoff doesn't match its definition.
\@dtl@lin@ ->;
              Besoin;Priorite;Preoccupations;Solution actuelle;Solution prop...
l.11 \DTLloaddb{data}{datatools3.csv}
                                     
! Undefined control sequence.
\iterate ...f \@dtl@lin@ \to \@dtl@lin@ \@dtl@key 
                                                  \advance \dtl@entrycr by 1...
l.11 \DTLloaddb{data}{datatools3.csv}
                                     
! Undefined control sequence.
\iterate ...er \@dtl@toks \expandafter {\@dtl@key 
                                                  }\@ifundefined {@dtl@inky@...
l.11 \DTLloaddb{data}{datatools3.csv}
...
Anyone been through this issue?
Last edited by davidonlaptop on Mon Oct 11, 2010 9:59 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

josephwright
Site Moderator
Posts: 814
Joined: Tue Jul 01, 2008 2:19 pm

datatool + custom separator + french

Post by josephwright »

In French, babel makes various characters active. This can be problematic, so I'd try putting

Code: Select all

\DTLsetseparator{;}  
\DTLloaddb{data}{datatools3.csv}
before loading babel (in the preamble), and see what happens.
Joseph Wright
davidonlaptop
Posts: 6
Joined: Sat Apr 03, 2010 9:45 am

datatool + custom separator + french

Post by davidonlaptop »

josephwright wrote:In French, babel makes various characters active. This can be problematic, so I'd try putting

Code: Select all

\DTLsetseparator{;}  
\DTLloaddb{data}{datatools3.csv}
before loading babel (in the preamble), and see what happens.
Great! Actually that works if the loading occurs before

Code: Select all

\begin{document}
Also I found out that if I am using accentuated characters in the header columns, i need to switch to utf8 instead of utf8x.

What do you mean by it makes the characters active? So there is special commands per language? I thought all commands started with the backslash.

Thanks Joseph!
davidonlaptop
Posts: 6
Joined: Sat Apr 03, 2010 9:45 am

datatool + custom separator + french

Post by davidonlaptop »

The final code reads like this:

Code: Select all

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{datatool}
\usepackage[utf8]{inputenc}  % utf8x causes problem with accents in header columns
\usepackage[frenchb]{babel}

% Data loading must occur in the preamble
\DTLsetseparator{;}
\DTLloaddb{data}{datatools3.csv}

\begin{document}

\begin{tabular}{llrrr}
  \bfseries Besoin &
  \bfseries Priorité &
  \bfseries Préoccupations &
  \bfseries Solution actuelle &
  \bfseries Solution proposée

  \DTLforeach{data}{\besoin=Besoin, \priority=Priorité, \preoccupation=Preoccupations, 
  \currentsolution=Solution actuelle, \newsolution=Solution proposee}{
    \\
    \besoin & \priority & \preoccupation & \currentsolution & \newsolution
  }
\end{tabular}
\end{document}

Code: Select all

Besoin;Priorité;Preoccupations;Solution actuelle;Solution proposee
John;"Smith, Jr";102689;68;68
Jane;Brown;102647;75;68
Andy;Brown;103569;42;68
Zoe;Adams;105987;52;68
Roger;Brady;106872;58;68
Clare;Verdon;104356;45;68
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

datatool + custom separator + french

Post by gmedina »

davidonlaptop wrote:...What do you mean by it makes the characters active? So there is special commands per language? I thought all commands started with the backslash...
The babel package supports "shorthands" (one- ot two-character sequences that act like commands even if they don't start with a backslash) and some languages (maybe all of them, but I can only speak for Spanish and French) implement specific shorthands.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
davidonlaptop
Posts: 6
Joined: Sat Apr 03, 2010 9:45 am

Re: datatool + custom separator + french

Post by davidonlaptop »

Is there a way to deactivate these shorthands?
Or is it not recommanded?
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

datatool + custom separator + french

Post by localghost »

davidonlaptop wrote:Is there a way to deactivate these shorthands?
Or is it not recommanded?
Search the babel manual for »shorthandon« and »shorthandoff« with regard to your language. You might turn the shorthands off where needed and turn them on later again.


Thorsten
davidonlaptop
Posts: 6
Joined: Sat Apr 03, 2010 9:45 am

Re: datatool + custom separator + french

Post by davidonlaptop »

OK thanks, I'll check that out.
Post Reply