Projet

Général

Profil

Wiki » Historique » Version 2

Jonathan Schaeffer, 06/06/2016 17:13

1 1 Jonathan Schaeffer
h1. Wiki
2
3 2 Jonathan Schaeffer
h2. Schéma de la base de donnée
4
5
[[schema]]
6 1 Jonathan Schaeffer
7
h2. astuces : ouverture d'un CSV non UTF-8
8
9
<pre>
10
2.1.2 :001 > require 'csv'
11
 => true 
12
2.1.2 :002 > handler = open('/home/schaeffer/tmp/exemple.csv')
13
 => #<File:/home/schaeffer/tmp/exemple.csv> 
14
2.1.2 :003 > csv_string = handler.read.encode!("UTF-8", invalid: :replace)
15
2.1.2 :004 > csv = CSV.parse csv_string, col_sep: ";", headers: true
16
 => #<CSV::Table mode:col_or_row row_count:8641> 
17
18
</pre>