<html style="direction: ltr;">
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<style type="text/css">body p { margin-bottom: 0cm; margin-top: 0pt; } </style>
</head>
<body style="direction: ltr;"
bidimailui-detected-decoding-type="latin-charset" bgcolor="#FFFFFF"
text="#000000">
On 10/22/2012 01:20 PM, Johannes Radinger wrote:
<blockquote
cite="mid:CABsGe_xs1NHvOhGX_vvW=fe_afVf-ptkzB2kESa1xUOcw5GJOg@mail.gmail.com"
type="cite">
<pre wrap="">Hi,
I have a points vector file with the columns X and Y which are
populated with the respective coordinates.
Additionally I have a .csv file for the same points, also with the X
and Y column and a lot more columns
providing additional information. These two files don't share a single
unique key which can be used for joining.
Thus I'd like to use the X-Y pair as a key for importing and then
joining the csv table
to the vector. Is there any possibility to use two columns as a
combined key instead of one
(probably an SQL statement for db.execute)? Or do I need to first
create a new column
and combine x and y into a key for the vector and the csv?
</pre>
</blockquote>
<br>
If the X-Y values are *exactly* the same then you probably could do
it directly in sqlite:<br>
First import the csv table into your sqlite.db<br>
sqlite>.import file.csv csv_table<br>
sqlite>.schema csv_table<br>
<br>
Now create columns in the vector table for each new column from the
csv table<br>
sqlite> ALTER TABLE vector ADD COLUMN from_csv_col1 text;<br>
sqlite> ALTER TABLE vector ADD COLUMN from_csv_col2 integer;<br>
...etc...<br>
<br>
Now update the values in each new column with the matching values
from the csv table:<br>
sqlite> UPDATE vector SET from_csv_col1=(SELECT c.col1 FROM
csv_table AS c <br>
... WHERE c.x_coord=vector.x_coord AND c.y_coord=vector.y_coord);<br>
<br>
and so on for all the new columns.<br>
HTH<br>
<br>
<blockquote
cite="mid:CABsGe_xs1NHvOhGX_vvW=fe_afVf-ptkzB2kESa1xUOcw5GJOg@mail.gmail.com"
type="cite">
<pre wrap="">
Any suggestions how that can be done in GRASS (6.5, sqlite) in a simple way?
Best regards,
Johannes
_______________________________________________
grass-user mailing list
<a class="moz-txt-link-abbreviated" href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/grass-user">http://lists.osgeo.org/mailman/listinfo/grass-user</a>
This mail was received via Mail-SeCure System.
</pre>
</blockquote>
<br>
</body>
</html>