From f671439f6f3594d2eae9d4d061081823d0f22174 Mon Sep 17 00:00:00 2001 From: Jeff Moe Date: Fri, 29 Sep 2023 08:13:06 -0600 Subject: [PATCH] regex fix json, issue #1 --- gbif-cruft-json | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/gbif-cruft-json b/gbif-cruft-json index 8bf80be..1f46969 100755 --- a/gbif-cruft-json +++ b/gbif-cruft-json @@ -18,7 +18,21 @@ along with this program. If not, see . """ # Sample code for issue #1 -from pygbif import species +#from pygbif import species +import re +import sys + +# Use GBIF API +#foo = species.name_suggest(q="Puma concolor") + +# Read file same as species.name_suggest() instead of hitting +# their API over and over. +f = open("sample/pumas.json") +foo = f.read() +foo = foo[:-1] + +foo = re.sub("\'", '\"', foo) +foo = re.sub("False", '"False"', foo) +foo = re.sub("True", '"True"', foo) -foo = species.name_suggest(q="Puma concolor") print(foo)