Skip to content

Instantly share code, notes, and snippets.

@Inkimar
Created July 27, 2020 12:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Inkimar/294cb6114a5868fd4ff2d8180213a662 to your computer and use it in GitHub Desktop.
Save Inkimar/294cb6114a5868fd4ff2d8180213a662 to your computer and use it in GitHub Desktop.
copy table with all content, database
create table redlist_tmp select * from redlist_2015;
@Inkimar
Copy link
Author

Inkimar commented Jul 27, 2020

mysql> select * from redlist_2015 where id=102963;

+--------+----------------------------+------------+-------------------------------------------------+--------------------------------------+------------------+---------------+---------------+-------------+
| id     | latin                      | svenskt    | pdf_url                                         | web_url                              | status           | status_abbrev | status_eng    | status_swe  |
+--------+----------------------------+------------+-------------------------------------------------+--------------------------------------+------------------+---------------+---------------+-------------+
| 102963 | Chroicocephalus ridibundus | skrattmås  | //artfakta.artdatabanken.se/artfaktablad/102963 | ca32a96f-bd50-47cc-8faf-57ddde90d5b8 | Livskraftig (LC) | LC            | Least Concern | Livskraftig |
+--------+----------------------------+------------+-------------------------------------------------+--------------------------------------+------------------+---------------+---------------+-------------+
1 row in set (0,06 sec)

@Inkimar
Copy link
Author

Inkimar commented Jul 27, 2020

library(tidyverse)
library(glue)
redlist <- read.csv("rodlistade_arter_tampered_2.csv",header=TRUE);
dat <- select(redlist,'id', 'status_abbrev')

df2 <- redlist %>% 
  mutate(sql_string = glue("update redlist SET status_abbrev='{status_abbrev}' where id={id}"))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment