[GRASS-user] sqlite and string function::how can I replace substrings in a table?

wqual wolfgang.qual at gmx.net
Tue Aug 8 05:23:52 EDT 2006


Hi Glynn, list,
at least, here's a possibility to search/replace substrings of the whole 
table:

1) within sqlite (export the table to a textfile):
sqlite> .output poi_orig.sql (set output file name)
sqlite> .dump poi_orig (write the table into the above named file)
sqlite> .exit (leave sqlite)

2) on the command-line do the following
sed -i 's/ö/oe/' ~/poi_orig.sql (replace all 'ö' with 'oe' within the whole 
table)

3) within sqlite
.read read poi_orig.sql (the *sql-file is read into a table)



Am Montag 07 August 2006 pH:31:21 nachmittags/abends schrieb Glynn Clements:
> wqual wrote:
> > I need to replace substrings in my sqlite-attribute-table (e.g. ß--> ss,
> > ä --> ae etc.). I am wondering, if this is possible (but sqlite says: no
> > such function substring, no such function replace!).
>
> SQLite has a "substr" function and a concatenation operator ("||"),
> but it doesn't have any way to find the index of the character which
> you want to replace.
>
> So, you would either have to export the table to a text file and
> modify that, or write an extension using SQLite's C/C++ API.




More information about the grass-user mailing list