emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Orgmode] [babel] Sh problem when echo'ing input data with ' inside


From: Eric Schulte
Subject: Re: [Orgmode] [babel] Sh problem when echo'ing input data with ' inside
Date: Mon, 17 Jan 2011 09:24:28 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

Hi Seb,

I can't reproduce this problem, on my system, I get the following
correct behavior

#+results: excel-from-bank
#+begin_example
Num.ro du compte :;979-9500975-24;Compte Maxi
Date valeur;R.f.rence de l'op.ration;Description;Montant de 
l'op.ration;Devise;Date d'op.ration;Compte de contrepartie;Nom de la 
contrepartie :;Communication 1 :;Communication 2 :
04-06-2009;A9F04NT01WK300TG;Virem. 
internet;420,00;EUR;04-06-2009;799-5900947-23;PAYEE ONE; ; 
24-02-2009;A9B24NT012K4018Z;Virem. 
internet;-54,93;EUR;24-02-2009;799-9974005-30;ME;Eigen rekening; 
18-05-2008;A8E19NT000S604QI;Virem. 
internet;-1.000,00;EUR;19-05-2008;799-8068445-18;PAYEE TWO; ; 
#+end_example

#+begin_src sh :var data=excel-from-bank :results output
echo "$data"
#+end_src

#+results:
: Num.ro du compte :;979-9500975-24;Compte Maxi
: Date valeur;R.f.rence de l'op.ration;Description;Montant de 
l'op.ration;Devise;Date d'op.ration;Compte de contrepartie;Nom de la 
contrepartie :;Communication 1 :;Communication 2 :
: 04-06-2009;A9F04NT01WK300TG;Virem. 
internet;420,00;EUR;04-06-2009;799-5900947-23;PAYEE ONE; ; 
: 24-02-2009;A9B24NT012K4018Z;Virem. 
internet;-54,93;EUR;24-02-2009;799-9974005-30;ME;Eigen rekening; 
: 18-05-2008;A8E19NT000S604QI;Virem. 
internet;-1.000,00;EUR;19-05-2008;799-8068445-18;PAYEE TWO; ;

and the sh code block expands to the following (with C-c C-v v) which is
not affected by commas...

#+begin_src sh
  data=$(cat <<BABEL_STRING
  Num.ro du compte :;979-9500975-24;Compte Maxi
  Date valeur;R.f.rence de l'op.ration;Description;Montant de 
l'op.ration;Devise;Date d'op.ration;Compte de contrepartie;Nom de la 
contrepartie :;Communication 1 :;Communication 2 :
  04-06-2009;A9F04NT01WK300TG;Virem. 
internet;420,00;EUR;04-06-2009;799-5900947-23;PAYEE ONE; ; 
  24-02-2009;A9B24NT012K4018Z;Virem. 
internet;-54,93;EUR;24-02-2009;799-9974005-30;ME;Eigen rekening; 
  18-05-2008;A8E19NT000S604QI;Virem. 
internet;-1.000,00;EUR;19-05-2008;799-8068445-18;PAYEE TWO; ;
  BABEL_STRING
  )
  echo "$data"
#+end_src

Are you on a windows machine?  I'm not sure what else could be different
about the shell environment on our machines.

Cheers -- Eric

note: some of the characters in your email weren't printable when I
tried to send this with gnus, so they've been replaced with "."s

Sébastien Vauban <address@hidden> writes:

> Hi,
>
> I tried to work on a CSV2Ledger, accepting the particular (European) CSV
> format of my bank:
>
> * Data
>
> #+results: excel-from-bank
> #+begin_example
> Num.ro du compte :;979-9500975-24;Compte Maxi
> Date valeur;R.f.rence de l'op.ration;Description;Montant de 
> l'op.ration;Devise;Date d'op.ration;Compte de contrepartie;Nom de la 
> contrepartie :;Communication 1 :;Communication 2 :
> 04-06-2009;A9F04NT01WK300TG;Virem. 
> internet;420,00;EUR;04-06-2009;799-5900947-23;PAYEE ONE; ; 
> 24-02-2009;A9B24NT012K4018Z;Virem. 
> internet;-54,93;EUR;24-02-2009;799-9974005-30;ME;Eigen rekening; 
> 18-05-2008;A8E19NT000S604QI;Virem. 
> internet;-1.000,00;EUR;19-05-2008;799-8068445-18;PAYEE TWO; ; 
> #+end_example
>
> * "Europeanize" the CSV file
>
> Here, we have to make several manipulations on the input file, such as:
> - remove dots from amounts
> - replace commas from amounts by dots
> - replace semi-commas by commas
> - etc.
>
> My goal is to make that as a suite of bash commands (=echo | cmd 1 | cmd 2=),
> tangled in a script file.
>
> However, I can't do any work on the input file, the very basic echo command
> already giving an error:
>
> #+begin_src sh :var data=excel-from-bank :results output
> echo "$data"
> #+end_src
>
> #+results:
> Code block produced no output.
>
> #+begin_src stderr
> sh: line 3: unexpected EOF while looking for matching `''
> sh: line 10: syntax error: unexpected end of file
> #+end_src
>
> In this sample, this is due to the apostrophe in the header line ("Montant de
> l'opération").
>
> Any idea on how to:
> - circumvent such problem?
> - or, eventually, do this better?
>
> Best regards,
>   Seb



reply via email to

[Prev in Thread] Current Thread [Next in Thread]