source: src/django_gheat/db/csv_to_db.php@ 9072

Last change on this file since 9072 was 9045, checked in by dennisw, 14 years ago

tijdelijke data invoer scripts toegevoegd

File size: 858 bytes
Line 
1<?php
2
3// edit with personal settings
4$location = ' ';
5$username = ' ';
6$password = ' ';
7$database = ' ';
8
9// csv to open
10$file = ' .csv';
11
12// connect to database
13mysql_connect($location, $username, $password)
14 or die("Error connecting to mysql: " . mysql_error());
15mysql_select_db($database)
16 or die("Error connecting to database: " . mysql_error());
17
18// insert data from csv into database
19if (($handle = fopen($file, "r")) !== FALSE) {
20 while (($data = fgetcsv($handle, 1000, "\t")) !== FALSE) {
21 $lat=str_replace("N ", "", $data[0]);
22 $lon=str_replace("E ", "", $data[1]);
23 $sgnl=str_replace("'", "", $data[2]);
24 $query=mysql_query("INSERT INTO gheat_meting (lat, lng, signaal) VALUES ('$lat','$lon','$sgnl')");
25 if (!$query) {
26 die('Invalid query: ' . mysql_error());
27 }
28 }
29 fclose($handle);
30}
31
32echo 'done';
33
34?>
Note: See TracBrowser for help on using the repository browser.