Skip to content

Instantly share code, notes, and snippets.

@KaceCottam
Last active May 5, 2021 00:05
Show Gist options
  • Save KaceCottam/165ae952e923d9c5dcbd764c8481c2c6 to your computer and use it in GitHub Desktop.
Save KaceCottam/165ae952e923d9c5dcbd764c8481c2c6 to your computer and use it in GitHub Desktop.
Simple parsing of a CSV file's line. Also includes a utility file repr.hpp and a main for testing.
#include <iostream> // std::ostream, std::cout, std::cin
#include "simpleCSVParse.hpp" // parseCSVLine, option
#include "repr.hpp" // Repr
// need to make representation for a optional value
template<class T>
struct Repr<option<T>> {
const option<T>& value;
explicit Repr(const option<T>& v) : value{v} {}
friend std::ostream& operator<<(std::ostream& lhs, const Repr& rhs)
{
if (rhs.value) return lhs << Repr<T>(*rhs.value);
else return lhs << '?';
}
};
template<class ...Args>
constexpr inline void outputLines(std::ostream& stream, const Args&... values)
{
((stream << Repr(values) << ' '), ...);
}
int main()
{
auto [a, b, c] = parseCSVLine<int,option<int>,int>(std::cin);
outputLines(std::cout, a, b, c);
auto [d, e, f] = parseCSVLine<option<char>,option<int>,char>(std::cin);
outputLines(std::cout, d, e, f);
auto [g, h, i] = parseCSVLine<option<std::string>,std::string,option<std::string>>(std::cin);
outputLines(std::cout, g, h, i);
// test input: 1,,4,,,c,"Bobby, Maximus",mom,,
// output: 1 ? 4 ? ? 'c' "Bobby, Maximus" "mom" ?
//auto [x,y,z] = parseCSVLine<int, option<int>, std::string>)std::cin);
// ^ basically expands to this at compile time.
int x;
option<int> y;
std::string z;
{ // begin new scope so _s cannot be used
std::string _s;
std::getline(std::cin, _s, ',');
std::stringstream(_s) >> x;
}
if (std::cin.eof()) {
y = nullptr;
} else if (std::cin.peek() == ',') {
y = nullptr;
std::cin.ignore(1);
} else {
int _data; // not accessible outside of the if statement
std::string _s; // not accessible outside of the if statement
std::getline(std::cin, _s, ',');
std::stringstream(_s) >> data;
y = std::make_unique<int>(std::move(data));
}
if (std::cin.peek() == '"') {
std::cin.ignore(1);
std::getline(stream, s, '"');
if (std::cin.peek() == ',') std::cin.ignore(1);
} else {
std::getline(std::cin, z, ',');
}
// which is basically what people normally write when parsing a line of CSV data...
}
#include <fstream>
#include <benchmark/benchmark.h>
#include "simpleCSVParse.hpp"
static void BM_parseCSVLine(benchmark::State& state) {
std::ifstream file("testcsv.csv");
std::string s;
std::getline(file, s);
for (auto _ : state) {
auto [id, species_name, country, howmany] = parseCSVLine<option<int>,std::string, std::string,option<int>>(file);
}
}
static void BM_manual(benchmark::State& state) {
std::ifstream file("testcsv.csv");
{
std::string s;
std::getline(file, s);
}
for (auto _ : state) {
option<int> id, howmany;
std::string species_name, country;
{
int _id = 0;
std::string s;
std::getline(file, s, ',');
std::stringstream(s) >> _id;
id = _id > 0 ? std::make_unique<int>(std::move(_id)) : nullptr;
}
if (file.peek() == '"') {
file.ignore(1);
std::getline(file, species_name, '"');
if (file.peek() == ',') file.ignore(1);
} else {
std::getline(file, species_name, ',');
}
if (file.peek() == '"') {
file.ignore(1);
std::getline(file, country, '"');
if (file.peek() == ',') file.ignore(1);
} else {
std::getline(file, country, ',');
}
{
int _howmany = 0;
std::string s;
std::getline(file, s, ',');
std::stringstream(s) >> _howmany;
howmany = _howmany == 0 ? std::make_unique<int>(std::move(_howmany)) : nullptr;
}
}
}
// Register the function as a benchmark
BENCHMARK(BM_parseCSVLine);
BENCHMARK(BM_manual);
// compile with `g++ googlebenchmark.cpp -std=c++17 -lbenchmark -lbenchmark_main -lpthread -O3
#ifndef REPR_HPP
#define REPR_HPP
#include <string> // need special handling for quotes
#include <iostream> // std::ostream
template<class T>
struct Repr {
const T& value;
explicit Repr(const T& v) : value{v} {}
friend inline std::ostream& operator<<(std::ostream& lhs, const Repr& rhs)
{
return lhs << rhs.value;
}
};
template<>
struct Repr<char> {
const char& value;
explicit Repr(const char& v) : value{v} {}
friend inline std::ostream& operator<<(std::ostream& lhs, const Repr& rhs)
{
return lhs << '\'' << rhs.value << '\'';
}
};
template<>
struct Repr<std::string> {
const std::string& value;
explicit Repr(const std::string& v) : value{v} {}
friend inline std::ostream& operator<<(std::ostream& lhs, const Repr& rhs)
{
return lhs << '"' << rhs.value << '"';
}
};
#endif
// Created by Kace Cottam, 4/6/2021
// Last modified 5/4/2021
#ifndef SIMPLE_CSV_PARSE_HPP
#define SIMPLE_CSV_PARSE_HPP
#include <string> // need special handling for quotes
#include <sstream> // std::stringstream
#include <iostream> // std::istream, std::ostream
#include <memory> // std::unique_ptr
#include <utility> // std::tuple, std::apply
// requires C++17
// compile with -std=c++17
template<class T>
using option = std::unique_ptr<T>;
template<class T>
constexpr inline std::istream& safeExtraction(
std::istream& stream,
T&& arg,
const char recordDelim,
const char)
{
std::string s;
std::getline(stream, s, recordDelim);
std::stringstream(s) >> arg;
return stream;
}
template<>
inline std::istream& safeExtraction(
std::istream& stream,
std::string& s,
const char recordDelim,
const char quoteDelim)
{
if (stream.peek() == quoteDelim) {
stream.ignore(1);
std::getline(stream, s, quoteDelim);
if (stream.peek() == recordDelim) stream.ignore(1);
} else {
std::getline(stream, s, recordDelim);
}
return stream;
}
template<class T>
constexpr inline std::istream& safeExtraction(
std::istream& stream,
option<T>& ptr,
const char recordDelim,
const char quoteDelim)
{
if (stream.eof()) {
ptr = nullptr;
} else if (stream.peek() == recordDelim) {
ptr = nullptr;
stream.ignore(1);
} else {
T data;
safeExtraction(stream, data, recordDelim, quoteDelim);
ptr = std::make_unique<T>(std::move(data));
}
return stream;
}
template<class ...Args>
constexpr inline std::tuple<Args...> parseCSVLine(
std::istream& stream,
const char recordDelim = ',',
const char quoteDelim = '"')
{
std::tuple<Args...> items;
std::apply(
[&stream, &recordDelim, &quoteDelim]
(auto&&... vals) {
((safeExtraction(stream, vals, recordDelim, quoteDelim)), ...);
}, items);
return items;
}
#endif
id name country howmany // generated from Mockaroo.com
1 Possum, common brushtail China 15655
2 Desert kangaroo rat China 613543
3 Porcupine, tree South Africa 375995
4 Pied cormorant China
Tortoise, burmese black mountain Indonesia 810184
6 Grey fox United States 359013
7 Canadian tiger swallowtail butterfly Azerbaijan 936486
8 Greater sage grouse China 17289
9 Tortoise, burmese black mountain Sweden 599659
10 Duiker, common Portugal 54567
11 Margay Ukraine 524961
12 Blue shark Mexico 856757
13 Wallaby, euro Syria 888696
14 Magpie, black-backed Mozambique 427313
Beisa oryx Niger 223445
16 Kangaroo, jungle Indonesia 320085
17 Hummingbird (unidentified) Indonesia
18 Gecko (unidentified) Peru 986480
19 Rufous tree pie Russia 309426
Gull, southern black-backed Ecuador
21 Tortoise, indian star China 65501
Steenbok Chad 848396
Giant otter Ukraine 783615
Galapagos mockingbird Afghanistan 604037
25 South American meadowlark (unidentified) Pakistan 778326
26 Black-capped chickadee Portugal 44971
27 South American puma Philippines 557434
28 Weaver, lesser masked Venezuela
29 African porcupine Indonesia 698970
Giant otter China 610893
31 Sidewinder Pakistan 201358
32 Rhesus monkey Sweden 506890
33 Wapiti, elk, Philippines 924774
34 Malay squirrel (unidentified) China
35 Small-spotted genet Malaysia 197961
36 Sun gazer Brazil 780965
Sungazer, yellow-brown Azerbaijan 806684
38 Pigeon, wood Armenia 418026
39 Stanley crane Mayotte
40 Toddy cat China 892515
41 Great egret Malaysia
42 Dog, black-tailed prairie South Africa 390288
Cheetah Switzerland 696000
44 Monster, gila China 214777
45 Jaeger, long-tailed Brazil 255940
46 Boa, emerald green tree Brazil 832061
47 Short-beaked echidna Canada 627296
48 Beaver, north american Sierra Leone 291787
49 Asian lion Indonesia 839591
Lark, horned United States
51 Dog, african wild Yemen 754127
52 Australian masked owl Poland 804416
53 Mongoose, banded Marshall Islands 442453
Owl, australian masked Russia 65784
Gray rhea New Zealand 466162
56 Ferret, black-footed Indonesia 75568
Tammar wallaby Latvia 507230
58 Bear, grizzly Croatia 8674
59 Deer, swamp China 614285
60 Brown antechinus Bosnia and Herzegovina 64108
61 Lilac-breasted roller Brazil 693939
62 Albatross, waved Finland 986458
63 Baboon, chacma China
64 Pine siskin Sweden 305829
65 Wattled crane Czech Republic 219979
66 Black bear Ireland 75655
67 Bottle-nose dolphin Pakistan 650177
68 Jungle kangaroo Bulgaria
69 Cat, long-tailed spotted Norway 161430
70 Black-capped capuchin Portugal 474214
71 Eastern grey kangaroo Poland 237669
Screamer, southern Tunisia 171226
Gorilla, western lowland Angola 455189
74 Squirrel, arctic ground Indonesia 653738
75 Gull, pacific Netherlands 224327
76 Hedgehog, south african Indonesia 911471
77 Genet, small-spotted Brazil 717778
78 Stork, white China 35367
79 Brown lemur Sweden 195944
80 Cormorant (unidentified) Poland 760587
81 Beaver, eurasian China 212855
82 Sacred ibis China
83 Starling, superb Zambia 532047
84 California sea lion Poland 510266
85 Snake (unidentified) Pakistan 549673
86 Goliath heron Japan 633936
Netted rock dragon Macedonia 970180
88 Flying fox (unidentified) France 351792
89 Eagle, crowned Philippines 479414
90 Cardinal, red-capped Indonesia 980666
91 Nile crocodile Poland 262323
92 Columbian rainbow boa Indonesia 77964
93 Gull, dusky Papua New Guinea 343430
Laughing dove Zambia 645963
95 Swan, black Russia 598175
96 Deer, savannah Indonesia 520321
97 Seal, southern elephant Russia 19504
Genoveva China 676080
99 Bear, american black China 700398
100 Parakeet, rose-ringed Zimbabwe 920652
Crow, house China 199325
102 Magnificent frigate bird Indonesia 899197
Lion, steller's sea Bulgaria 214377
104 Openbill, asian Ghana 469542
105 Possum, western pygmy Croatia 124081
106 Caiman, spectacled China 66756
107 Black-capped chickadee Czech Republic 662361
108 Savanna fox Portugal 818548
109 Bird, secretary France 387275
110 Richardson's ground squirrel South Africa
Yellow-bellied marmot China 886190
112 Squirrel, grey-footed Peru 595269
113 Python, carpet South Africa
114 Red-billed tropic bird Cuba 76334
115 Cat, kaffir Indonesia 786067
116 Siskin, yellow-rumped Indonesia 773559
117 Chickadee, black-capped Curacao 52962
Fox, cape China 344223
119 Grey-footed squirrel Indonesia 752633
120 Dragon, frilled Iceland 159468
African clawless otter Indonesia 152352
122 African polecat Russia 129371
Black-faced kangaroo France 63944
124 Bustard, denham's South Africa 8631
125 Lava gull United States 657298
126 Tiger France 506884
127 Kangaroo, western grey Thailand
128 Monster, gila China 213505
129 Bushbaby, large-eared Vietnam 661103
130 Pied kingfisher Thailand 284434
Bushpig Colombia 581911
132 Brazilian otter Sweden 350237
133 King cormorant Indonesia 890308
134 Monitor, white-throated China 411597
135 Greater roadrunner Ivory Coast 554251
136 Common rhea Papua New Guinea 261865
137 Hoary marmot United States 201537
138 Whale, southern right Greece 715550
139 Heron, green Indonesia 460878
140 Dassie Somalia 685751
141 Violet-eared waxbill Philippines 461175
142 Masked booby Japan 941364
Turaco, violet-crested Philippines 137187
144 Lorikeet, scaly-breasted China 532586
145 Polecat, african Philippines 324190
146 Cormorant, flightless Austria 838305
147 Egret, cattle Sweden 630241
148 Green-winged macaw Portugal 494378
149 Pig-tailed macaque Peru 681173
150 Plover, blacksmith South Africa 803470
White-headed vulture Portugal 192320
Macaque, japanese Philippines 379260
153 Green heron France 904690
154 Capuchin, white-fronted Armenia 85524
155 Stanley bustard China 889073
Zorro, common Greece 984694
Fairy penguin Peru 139257
158 Pronghorn Tajikistan 953609
Waterbuck, common China 425754
160 Blue-tongued lizard Russia 667660
161 Stork, white-necked Madagascar 701003
Rhea, gray Egypt 619878
163 Comb duck Panama 813018
164 Beaver, eurasian Japan 478284
Ringtail cat Portugal 272346
166 Long-tailed skua Tanzania 411547
167 Hen, sage United States
168 Wood pigeon Portugal 511853
169 Squirrel, nelson ground Indonesia
170 North American red fox Indonesia 625200
171 Bat-eared fox China 230852
172 Steller sea lion China 840401
173 Tree porcupine Japan 763912
174 Goldeneye, common France
175 Southern lapwing Brazil 334716
176 Snake, western patch-nosed Malaysia 674859
177 Blue duck China 867110
Otter, small-clawed South Korea 404623
179 Macaque, pig-tailed China 542713
180 Cape cobra China 673330
181 Mississippi alligator China 798075
182 Kaffir cat Portugal 251804
183 Common long-nosed armadillo Norway 331897
Macaque, japanese Czech Republic 467362
185 Kiskadee, great Tunisia 430773
Four-striped grass mouse Pakistan 404286
187 Killer whale China 942518
188 Eagle, golden Poland 957016
189 African red-eyed bulbul Sweden 487406
190 Goat, mountain United Kingdom 451206
191 Common brushtail possum Poland 793631
192 Crane, sandhill Portugal 318178
193 Desert kangaroo rat China 362693
194 Waterbuck, defassa Indonesia 543867
195 Stork, marabou Japan 611400
196 Ibis, glossy Dominican Republic 18111
197 Brindled gnu Peru 529361
Coot, red-knobbed Ireland 858356
199 Alpaca Brazil 942197
200 Oriental short-clawed otter Nicaragua 425314
201 Impala Indonesia 864389
202 Bee-eater (unidentified) Portugal 717701
Openbill, asian Mongolia 647156
204 Bennett's wallaby Angola 938258
205 Rose-ringed parakeet Philippines 661096
206 Magpie, australian China 997211
207 Four-striped grass mouse Philippines 287722
208 Japanese macaque Colombia 166054
209 Pheasant, common Honduras 122338
Skimmer, four-spotted Armenia 456372
211 Siskin, yellow-rumped Finland 595912
212 Nyala Guatemala 794043
213 Greater blue-eared starling Portugal 658247
214 Mockingbird, galapagos Portugal 541376
215 Smith's bush squirrel Afghanistan
216 Owl, burrowing Indonesia 711501
217 Macaw, green-winged Lebanon
Squirrel, eastern fox Japan 832841
219 White-fronted bee-eater Canada 880854
220 Green-winged macaw Canada 594930
221 Ibis, glossy Canada 196528
222 Bleu, blue-breasted cordon China
223 Weaver, red-billed buffalo Uruguay 260470
224 Goose, spur-winged China 108920
225 Blue-footed booby Ireland 707365
226 Leopard, indian Netherlands 463421
227 Waterbuck, defassa Philippines
Macaw, green-winged China 875213
229 Common green iguana Guinea
230 Tortoise, burmese black mountain North Korea 234562
231 Duiker, common Sudan 290376
232 Bee-eater, carmine Chile 493054
233 Javanese cormorant Philippines 540600
234 African lion Czech Republic 538596
235 Fox, pampa gray Bosnia and Herzegovina 982102
African skink Afghanistan 707667
Stork, saddle-billed Sweden 430691
238 Mexican boa Croatia 895320
Porcupine, tree Pakistan
240 European shelduck Argentina 481009
241 Woodcock, american China 354747
Long-finned pilot whale Indonesia
243 Porcupine, prehensile-tailed Russia 500561
Bottle-nose dolphin China
245 Hottentot teal Philippines 416542
246 Spotted hyena Czech Republic 288097
247 Flamingo, chilean Russia 741081
248 Australian brush turkey Indonesia 845129
249 Mongoose, small indian Colombia 328826
250 Moccasin, water Chile 571834
251 Saddle-billed stork Philippines 628652
252 Chital Thailand 516607
253 Long-tailed jaeger Afghanistan 602285
254 Short-beaked echidna United States 398942
255 Heron, gray Portugal 68686
256 Otter, giant Poland 372122
Moccasin, water Colombia 133678
258 Swan, black Indonesia 276754
259 Southern brown bandicoot Uruguay 539026
Weaver, lesser masked Argentina
261 Otter, small-clawed Indonesia 237111
Wombat, southern hairy-nosed United States 287899
263 Tiger snake Indonesia 74684
264 Mongoose, javan gold-spotted Japan
Crab-eating raccoon Morocco 866779
266 Francolin, coqui China 658807
267 Common wombat Thailand 41729
268 Greater roadrunner Peru 170469
269 Crested porcupine China 798319
Grouse, sage Democratic Republic of the Congo 219818
Verreaux's sifaka Brazil 752998
272 Onager Greece 246271
273 Hen, sage United States 871682
274 Red-breasted nuthatch Indonesia 344913
275 Antechinus, brown Syria 79853
276 Pelican, australian Argentina
277 Moorhen, purple Vietnam
278 White-rumped vulture Japan 468596
Swamp deer Kenya 348702
280 White-necked raven China 786747
Emu China 721916
Peacock, indian Russia 951524
283 Eurasian beaver Aland Islands 971914
284 Squirrel, red France
285 Cockatoo, roseate Belarus 929279
Mongoose, small indian Brazil
287 Opossum, american virginia China 917884
288 Capybara Russia 719823
289 Scaly-breasted lorikeet Russia 987582
Marten, american Bosnia and Herzegovina 340638
291 Seven-banded armadillo Philippines 199968
292 Collared peccary Ukraine 266792
293 Siskin, pine Portugal 471889
Deer, swamp Indonesia 319896
295 Magellanic penguin China 737852
296 Cook's tree boa Australia 784481
297 Japanese macaque Argentina 176140
298 Lizard, giant girdled Cameroon 19844
299 Common genet China 880719
300 Tokay gecko Poland
Owl, snowy Argentina 572688
302 Hawk, ferruginous Indonesia 774587
303 Worm snake (unidentified) Guatemala 487396
Springhare Indonesia 155228
305 Red brocket Japan 79599
Scottish highland cow Russia 889693
307 Crown of thorns starfish Greece 287490
308 Deer, white-tailed Sweden 732793
309 White-faced tree rat Brazil 525624
310 Herring gull Indonesia 878465
American black bear Poland 414645
Corella, long-billed Philippines 541390
313 Yellow-headed caracara Burkina Faso 201766
314 Kalahari scrub robin Russia 926590
Gila monster Russia
316 Agama lizard (unidentified) China 611728
317 Elephant, asian Yemen 847955
318 South American meadowlark (unidentified) Japan 465205
319 Dove, emerald-spotted wood Vietnam 527293
320 Lemur, ring-tailed France 283447
321 Owl, burrowing Brazil
322 Teal, hottentot Japan 473502
323 Booby, blue-faced Indonesia 592642
Tortoise, burmese black mountain Japan 795972
325 Puma, south american Poland 719204
326 Emu Poland 119353
327 Red-tailed phascogale Poland 559774
328 Pelican, australian Mexico 895410
329 American bison Mexico
330 Rainbow lory Iran 668740
331 Tortoise, burmese black mountain Croatia
332 Bustard, kori Portugal 825711
333 Fox, arctic Japan 563359
334 Stork, european Russia 189994
335 Dolphin, bottle-nose Indonesia 575003
336 Cat, kaffir Indonesia 508458
337 White-bellied sea eagle China 729676
Heron, giant Indonesia 700793
339 Shrew, mandras tree Japan
340 Snowy owl China 770653
Malagasy ground boa Philippines 987287
Owl, australian masked Indonesia 835130
343 Cockatoo, roseate Croatia
344 Hedgehog, south african Indonesia
345 Meerkat, red Portugal 171249
Eleven-banded armadillo (unidentified) Canada 356220
347 Gelada baboon Philippines 897245
Lemur, brown Indonesia 200686
349 Raccoon, common Bulgaria 506549
350 Bushbaby, large-eared China
351 Western bearded dragon China 332648
Dragon, netted rock Russia 418218
353 Emerald-spotted wood dove Sweden 940716
354 Eurasian badger Poland 605241
355 Woodchuck Indonesia 977492
356 Lory, rainbow Israel 260336
357 Reedbuck, bohor Belarus 279341
Capuchin, white-fronted Armenia 956723
359 Moccasin, water Indonesia 792269
360 Iguana, marine Philippines
361 Southern right whale Croatia 305621
362 Old world fruit bat (unidentified) China 725984
363 Australian brush turkey Russia 465777
364 African fish eagle Peru 765034
Mynah, indian Philippines 588506
366 Green-backed heron Gambia 597123
367 Otter, african clawless Palestinian Territory 982044
Cat, native China
369 Asiatic jackal Philippines 691484
370 Common goldeneye China 225615
371 Waxbill, violet-eared Peru 599053
372 Swainson's francolin Ireland 668607
373 Pocket gopher (unidentified) Haiti 974007
374 Whip-tailed wallaby Poland 642662
375 Gray duiker France 343861
376 Ring-tailed gecko China 809036
Sage hen China 428346
Squirrel, european red Portugal 694110
379 European badger Indonesia 742366
380 Otter, north american river Philippines
Asian false vampire bat Indonesia 862913
382 Darwin ground finch (unidentified) Brazil 103500
383 Beaver, eurasian Mongolia 872396
384 Boa, malagasy ground Portugal 226642
Common goldeneye Japan 419461
Stork, openbill China
Nighthawk, common Israel 695011
388 Seal, northern fur South Africa 37434
Common zebra Albania 837814
390 Phalarope, northern Yemen 92497
Grizzly bear Sweden 668750
392 Heron, green Sweden 934446
393 Kiskadee, great China 472105
394 Monitor, white-throated China 942529
395 Kangaroo, black-faced Netherlands 661450
396 Tailless tenrec Canada 308164
Bulbul, black-eyed Japan 113821
398 Red kangaroo China 552762
399 Alligator, mississippi South Africa 225664
400 Trumpeter swan Japan
401 Cattle egret Czech Republic 554379
402 Topi China 793202
403 Cormorant, neotropic Brazil 330378
404 Gull, herring China 880264
405 Springbok Ukraine 458245
406 Secretary bird Norway 945590
407 Barbet, levaillant's Serbia 424803
408 Devil, tasmanian Brazil 744002
409 Coyote Brazil 773629
410 Western pygmy possum Poland 905258
411 Rhesus monkey Thailand 518399
412 Palm squirrel Russia 722588
413 Plover, three-banded Yemen 419412
414 Lorikeet, scaly-breasted Estonia 558275
415 Least chipmunk China 607081
416 Dove, laughing China 217832
Raccoon dog Indonesia 717822
Coatimundi, white-nosed Brazil
419 Tropical buckeye butterfly Indonesia 187080
Hyrax Brazil
Alligator, mississippi Japan 102631
422 Kookaburra, laughing Hungary 318127
423 Heron, little Brazil 481067
Ferret, black-footed Honduras 285708
White spoonbill Czech Republic
426 American Virginia opossum Nigeria 846407
427 North American red fox Sweden 574616
Campo flicker China 961366
429 Cape clawless otter Honduras 512774
Deer, mule Argentina 25475
Rhea, gray North Korea 32589
432 Stork, white-necked Indonesia 390153
433 American marten Central African Republic
434 Magnificent frigate bird Colombia 831892
435 Ring-tailed coatimundi Portugal 817289
Crow, pied Russia 929745
437 Jackrabbit, white-tailed Guatemala 270609
438 Pie, rufous tree China 345198
439 Adouri (unidentified) Russia 214951
440 Asian water buffalo Lithuania 178878
441 Brown hyena Poland 119026
442 Huron Indonesia 155277
443 Yellow-crowned night heron Czech Republic 47432
444 Arctic ground squirrel Canada 89550
445 Eagle, tawny Portugal 482246
446 Azara's zorro Brazil 350887
447 Japanese macaque China 757453
448 Dark-winged trumpeter China
449 White-throated monitor Vanuatu 563517
450 Green-winged trumpeter China 875364
Verreaux's sifaka Peru 365288
Grizzly bear China 270289
453 Heron, yellow-crowned night Indonesia 94273
454 Green vine snake Botswana 65260
455 Iguana, marine Morocco 892629
456 Cat, long-tailed spotted Sweden 496017
457 Woylie Portugal 548839
458 Crane, sandhill Democratic Republic of the Congo 482874
459 Wild boar Poland 744982
460 Southern elephant seal Peru 690366
Wambenger, red-tailed El Salvador 791493
Land iguana Switzerland 729396
Nyala China 218605
464 Purple moorhen Serbia
Reedbuck, bohor Japan
466 Beaver, eurasian Denmark
Margay Democratic Republic of the Congo 201631
468 Arctic lemming Bosnia and Herzegovina 970968
Pygmy possum China 694887
Weaver, sociable Colombia 39975
471 Gonolek, burchell's Ukraine 923936
472 Mudskipper (unidentified) Nicaragua 338211
473 Kangaroo, jungle Indonesia 698496
474 Crimson-breasted shrike China 734150
475 Hyena, striped Bolivia 61463
Bahama pintail China 338653
477 Galapagos mockingbird China 960656
478 Cockatoo, red-breasted Russia 444836
479 Stork, painted Brazil 167226
480 Civet, common palm United States 8134
481 Snake-necked turtle Colombia 94240
482 Crown of thorns starfish China 235628
483 Mongoose, banded Egypt 32497
484 Grouse, sage China 193903
485 Egyptian cobra Thailand 318891
Armadillo, nine-banded Portugal 846271
487 Starling, red-shouldered glossy Portugal 485778
488 Dove, rock Libya 625960
489 Blackbird, red-winged China 941291
490 Rattlesnake, dusky Philippines 504053
491 Stilt, black-winged Brazil 71096
Brocket, red Egypt 804350
Pig-tailed macaque Peru 360187
Meerkat, red Brazil
495 Great cormorant Czech Republic 170699
496 Sandpiper, spotted wood China 92353
497 Sloth, two-toed Philippines 413585
498 Llama China 342471
499 Great horned owl Japan 895786
500 Yak Cameroon 87235
Elegant crested tinamou Indonesia 378332
502 Jackrabbit, white-tailed United States 67990
White-headed vulture Spain 188920
504 Salmon, sockeye France 652185
505 Cat, toddy Nepal 962345
506 Golden eagle Peru 830808
507 Eurasian badger Mexico 232336
508 Campo flicker China 878340
Marabou stork Indonesia 58814
510 Common shelduck China 657475
511 Antelope, roan Albania 926705
Blue racer Russia 352129
513 Roseat flamingo Canada 725461
514 Duck, blue Syria 517051
Nuthatch, red-breasted Indonesia 722687
516 Duiker, common Sweden 441225
517 North American porcupine China 359738
518 Hyena, brown China 466024
519 Gull, swallow-tail Indonesia 343624
520 Asian lion Kazakhstan 318552
521 Stone sheep China 589546
522 Vulture, turkey Philippines 935471
523 Badger, american Colombia 825055
524 Kookaburra, laughing Brazil 129207
525 Openbill, asian Peru 662587
526 Gull, herring Thailand 829886
Groundhog China 555359
528 Blue fox China 157644
Guanaco Morocco 125360
530 Egyptian viper China 765932
531 Deer, roe Brazil 709507
532 Mexican boa Kazakhstan 699808
Civet, small-toothed palm China 528898
534 Red-cheeked cordon bleu Nigeria
535 Beaver, eurasian Ivory Coast 714580
536 Jaguar China
Small-clawed otter Vietnam 351979
538 Fox, savanna Vietnam 66154
539 Openbill stork Philippines 945847
540 Marmot, hoary Philippines 440732
Cormorant, large China 953705
542 Wolf, timber Brazil 705914
Common zebra Poland 384733
Ant (unidentified) China 353002
545 Striped skunk Honduras 185009
546 Gecko, barking Costa Rica 852979
547 Pelican, eastern white Czech Republic 174664
Downy woodpecker United States 151150
Caracal China 879798
550 Macaque, japanese Indonesia 101519
551 Wallaby, whip-tailed Indonesia 171493
552 Plains zebra China 783667
553 Great kiskadee Peru 980207
Large cormorant Argentina
555 Bustard, kori Moldova 448411
556 American black bear United States 196211
557 Springbuck China 819040
558 Snake, green vine Indonesia 599789
559 Asian lion New Zealand 627804
560 Silver-backed jackal Brazil 459314
561 Possum, common brushtail Brazil 56555
562 Lemur, lesser mouse France 263917
563 Dove, rock Poland 387990
Sun gazer France 120387
565 Snake, tiger Peru
566 Yellow-brown sungazer Bolivia 76173
Vulture, bengal China 994876
568 Dog, black-tailed prairie Russia 604885
569 Wombat, southern hairy-nosed Paraguay 637944
570 Blue and gold macaw Indonesia 874407
571 Richardson's ground squirrel Ecuador 953886
Tortoise, radiated Netherlands 720188
Springbuck Philippines 12374
574 Green-winged trumpeter Indonesia 40906
575 Vulture, turkey Brazil
White-winged black tern France 211492
577 Lion, mountain Finland 43878
578 Turkey vulture Brazil 591386
579 Bottle-nose dolphin Indonesia 774590
Bald eagle China 699509
581 Yellow-brown sungazer China 96774
Malachite kingfisher Brazil
583 White-rumped vulture Philippines 764331
584 American Virginia opossum Spain 307909
585 Chital United States 861272
586 Orca Yemen 298448
587 Legaan, water China 873059
588 Wolf, common Mongolia 733733
589 Anaconda (unidentified) China 450401
590 Dusky gull Russia 414822
Black-tailed tree creeper Democratic Republic of the Congo 466542
Flamingo, greater Colombia 25647
593 Loris, slender Russia 64426
594 Pallas's fish eagle Peru 702626
595 Caiman, spectacled China 795420
Armadillo, common long-nosed Brazil 29416
597 Puma Portugal 508065
598 Netted rock dragon Honduras 125451
599 Sockeye salmon China 724479
600 Hawk-headed parrot Portugal 217017
601 Sportive lemur Pakistan 377582
602 Hippopotamus Macedonia 750145
603 Eleven-banded armadillo (unidentified) Canada 172218
604 Springhare Ukraine 398743
605 Macaque, bonnet Portugal 960570
Stork, european Russia 446829
607 Antelope, sable China 153696
608 Lemur, brown Brazil 595891
609 Vine snake (unidentified) Brazil 537742
610 Common genet Egypt 863222
611 Sloth, hoffman's Vietnam 478069
612 Caracara (unidentified) Syria 698646
613 Genoveva Poland 671318
614 Caribou Indonesia 950915
615 Cougar Saudi Arabia 266111
616 Macaw, blue and yellow Russia 809086
617 Dama wallaby Tanzania 198516
618 Mudskipper (unidentified) Vietnam 706309
Madagascar fruit bat China 97981
620 Squirrel, pine Indonesia 626203
621 Australian masked owl Tunisia 994136
622 Black swan Czech Republic 856809
623 Stanley crane Sweden 264650
Deer, roe Indonesia
625 Wolf, common Kazakhstan 357048
626 Sable antelope Czech Republic 92559
627 Bee-eater, white-fronted Indonesia 912491
628 Bird, secretary Russia 212978
Yellow-rumped siskin China 958597
Moorhen, purple Philippines
631 Long-finned pilot whale China 234178
632 Fox, cape China 256501
633 Eastern dwarf mongoose Dominican Republic 382834
634 Crested bunting Russia
635 Lourie, grey Macedonia 625462
636 Vulture, white-headed Indonesia 496300
637 Fox, blue China 442330
638 Wild turkey Slovenia 185023
639 Rat, arboral spiny Brazil 208093
640 Duck, comb China 162854
White-winged tern Nigeria 388444
642 Giant anteater United States
643 Turaco, violet-crested Russia 890913
644 Komodo dragon Mexico 605081
645 Monitor lizard (unidentified) Brazil 455969
Pale-throated three-toed sloth Indonesia 541989
647 Common melba finch Iran 329686
648 Egyptian cobra Indonesia 495579
649 Prehensile-tailed porcupine Afghanistan 54106
650 Weaver, red-billed buffalo China 805255
651 Buffalo, african China 197587
652 Aardwolf China 518213
Iguana, land Argentina 776467
Coatimundi, white-nosed China
Elephant, african China 413070
656 Old world fruit bat (unidentified) Indonesia 379703
657 European shelduck Russia 945885
658 Two-banded monitor China 827696
659 Cormorant, neotropic Indonesia 189578
660 Bird, bare-faced go away France
661 Blue shark Portugal
Red-billed buffalo weaver Cameroon 948158
663 African red-eyed bulbul Panama 804950
Tasmanian devil Dominican Republic 756825
665 Snow goose China 872604
666 Small-toothed palm civet Ethiopia 879592
667 Great white pelican Chad 496
668 Pigeon, wood Lebanon 891457
Blue-footed booby Thailand 851631
670 Bird, black-throated butcher Argentina 982922
671 Cape cobra Greece 669868
672 Egret, great Indonesia 884883
673 Snowy egret Indonesia 259696
Bulbul, black-eyed Japan 20534
675 Cat, jungle Indonesia 361273
676 Macaque, bonnet Malaysia 765286
Cobra, egyptian Indonesia 726870
678 Tawny eagle Indonesia 242509
679 Snake, western patch-nosed Indonesia 525615
680 Fork-tailed drongo Mexico 551906
681 Sulfur-crested cockatoo Vietnam 101337
682 Greylag goose Brazil 998744
Radiated tortoise Indonesia 951289
Legaan, ground Portugal 22897
Weaver, white-browed sparrow China 126551
686 Southern screamer Indonesia 295261
Boa, mexican Brazil
Waved albatross Ivory Coast 485747
689 Hottentot teal Philippines 912894
690 Black-fronted bulbul United States 368362
691 Wood pigeon Czech Republic 117459
692 Monster, gila Sweden 311646
White-winged dove Thailand 272125
694 Tortoise, radiated Argentina 545962
695 Rhesus macaque Italy 904667
696 Southern black-backed gull Poland 778232
697 Weaver, white-browed sparrow France 245630
698 Jackal, indian China 453601
699 Brazilian tapir Sweden 493190
700 Raccoon, common China 538034
701 Black-tailed prairie dog Chad 27968
702 Bleu, red-cheeked cordon Indonesia 97594
Shrike, common boubou Colombia
Cat, miner's China 569952
Praying mantis (unidentified) China 755595
706 Lesser mouse lemur China 970974
707 Greater blue-eared starling Malawi 478632
708 Genet, small-spotted Iraq 538033
709 Paca China 928597
710 Cobra, egyptian Philippines 136850
711 Gerenuk Czech Republic 513235
712 Horned puffin Namibia 489143
713 Beisa oryx China 718634
Steenbok Finland 795167
715 Rufous tree pie Nigeria 950008
716 Stick insect Benin 201179
717 Flamingo, roseat Greece 760943
718 Monitor, water Estonia
719 Red hartebeest Poland 17961
720 Tarantula China 621124
721 Black-backed magpie China 351454
722 White-cheeked pintail Ukraine
723 Feral rock pigeon Azerbaijan 921069
724 Numbat Indonesia 546309
Greater rhea South Africa 838736
726 Jacana, african Egypt 216017
Lynx, african Indonesia 964380
728 Turaco, violet-crested Russia 962648
729 Starling, greater blue-eared Tanzania 644332
730 Badger, american Marshall Islands 617396
Barbet, levaillant's Canada 964513
732 Praying mantis (unidentified) Brazil 217262
733 Bustard, stanley Indonesia 807859
734 Bear, sloth United States 473209
735 Fairy penguin South Africa 920725
736 Civet (unidentified) Afghanistan 116257
737 Weaver, lesser masked China 273484
738 Pied kingfisher El Salvador 787687
739 Red kangaroo Portugal 274488
740 Loris, slender Kenya 341716
741 Common goldeneye China 978657
742 Albatross, waved Indonesia 32416
743 Eurasian badger Nicaragua 116629
744 Kiskadee, great Serbia 61538
745 Crab-eating fox China 976184
746 North American porcupine China 545784
747 Yellow-rumped siskin Philippines 640525
748 Brazilian otter Russia 254253
White-throated monitor China 38699
Rhinoceros, black France
751 Gull, lava Czech Republic 335485
752 Eagle, golden Poland 158386
753 Coqui francolin Poland 987998
Platypus Democratic Republic of the Congo 595240
755 Osprey Philippines 785380
756 Mara Indonesia 292417
757 Dusky rattlesnake Comoros 337918
758 Brindled gnu Afghanistan 895242
759 Yellow-billed stork Russia
760 Tern, white-winged China 176899
761 Gorilla, western lowland Morocco 127521
762 Four-spotted skimmer China 792266
763 Python, carpet Jamaica 915575
Indian peacock Russia 825299
Bustard, kori Philippines 120104
King cormorant Russia 367266
767 Frilled lizard United States 56315
768 Crane, sarus Brazil
Uinta ground squirrel Russia 752148
770 White-throated robin Russia 53962
771 Galapagos dove Indonesia 21842
772 Fox, pampa gray Brazil 291171
773 Sifaka, verreaux's Poland 222401
774 Deer, savannah China 94995
775 Radiated tortoise Portugal 211481
776 Caiman, spectacled China 213660
777 Giant heron Saudi Arabia 13043
Gnu, brindled China 506986
779 Kalahari scrub robin China 977842
780 Insect, stick Paraguay 920341
781 Mynah, indian Japan 637250
782 Falcon, prairie Philippines 41242
Swan, black Philippines 877789
784 Giant anteater Portugal 725530
785 African lynx Russia 807071
786 Sandpiper, spotted wood Ukraine
787 Black-necked stork China 804666
788 Steller sea lion Croatia 556277
789 Common green iguana Canada
790 Boa, malagasy ground Ukraine 37099
791 Koala Djibouti
792 Indian red admiral Brazil 898696
793 Greater roadrunner Russia 596997
794 Glider, squirrel Russia 825262
Black swan Indonesia 60290
796 Grizzly bear Brazil 755143
Kangaroo, black-faced Syria 783347
798 Mocking cliffchat Netherlands 423095
799 Crimson-breasted shrike Pakistan 40075
800 Colobus, white-mantled Ivory Coast 136405
801 Black rhinoceros Mexico 755829
802 Cape cobra China 259276
Asian openbill Finland 343302
804 Badger, american Slovenia 163503
805 Uinta ground squirrel Indonesia 586430
806 African skink China 496747
807 Eastern dwarf mongoose Dominican Republic 631987
Tarantula, salmon pink bird eater Portugal 563113
Possum, ring-tailed Russia 203415
810 White spoonbill Czech Republic 845379
811 Robin, kalahari scrub Finland 518972
812 Caracara (unidentified) Russia 796494
813 Squirrel, indian giant Russia 2473
Cormorant (unidentified) Morocco 915480
815 Leopard Hungary 619820
816 White spoonbill Russia 483523
817 Tailless tenrec Armenia 930164
818 Yak Brazil 560477
819 Grebe, little Georgia 807566
820 Magellanic penguin China 466767
821 Toucan, white-throated Ukraine 435915
822 Hawk, red-tailed Sweden 111233
823 Heron, green-backed China 390683
824 California sea lion China 652554
825 Pied butcher bird Argentina 389956
826 Blue-tongued lizard South Africa 334633
827 Langur, common Poland
828 Rainbow lory Canada
829 Penguin, galapagos Indonesia 752743
830 Grey lourie China 146581
Pig-tailed macaque Egypt 138753
832 Mara China 155301
Bulbul, black-eyed Greece 188788
834 Pie, rufous tree Russia 890227
835 Common green iguana China 676076
836 Bison, american Bolivia 749069
837 Lappet-faced vulture Sweden 989133
838 American woodcock Finland 720095
839 Vulture, griffon Peru 820559
Snake-necked turtle Venezuela 392503
841 Pelican, eastern white China
842 Baleen whale Portugal 31960
843 Black-necked stork Poland
844 Dove, galapagos France 566471
845 Grey mouse lemur Sri Lanka 18107
846 Squirrel, palm Portugal 986428
847 Eastern grey kangaroo Sweden 887887
848 Indian peacock Botswana 234033
Wallaby, red-necked Sweden 244879
850 Red deer Philippines 156174
851 Capuchin, white-fronted Canada
852 Avocet, pied China 498427
853 Spoonbill, european Indonesia
854 Swallow-tail gull Vietnam 586824
Otter, african clawless Indonesia
856 Greylag goose Indonesia 237221
857 Striped hyena China 967399
858 Purple moorhen Indonesia 412389
859 Blue fox Afghanistan
860 Owl, great horned Russia 346959
861 Wallaby, red-necked Portugal 124195
Sulfur-crested cockatoo China 81656
863 Warthog Colombia
864 Bettong, brush-tailed Thailand 440177
865 Wallaby, whip-tailed China 269775
866 Lemming, collared Indonesia 68508
Cormorant, king Indonesia 885918
868 Kingfisher, malachite Brazil 714919
Common wallaroo Japan 99759
870 Snake, green vine France 24841
871 Drongo, fork-tailed United States 30597
872 Giant heron Portugal 748587
873 Blue peacock Indonesia 213706
874 Pied cormorant Bolivia 328746
875 White-throated toucan Canada 853187
876 Rhesus monkey Nicaragua 655431
877 Common nighthawk Colombia 331314
878 Porcupine, indian Indonesia
879 Buffalo, wild water France
880 Pheasant, common Brazil 946014
Turtle, snake-necked Iran 365038
882 Mocking cliffchat China 583714
Bird (unidentified) Indonesia 486539
884 Two-toed tree sloth Greece 61814
885 Gull, kelp Sweden
Lizard, mexican beaded Philippines 961747
887 Coyote China 966754
888 Ant (unidentified) Indonesia 788114
889 Pelican, great white Colombia 560012
890 Fox, silver-backed France 38114
891 Goose, knob-nosed Ireland 768884
892 Goanna lizard Indonesia 578505
893 Helmeted guinea fowl Vietnam 145363
894 Red-tailed wambenger Iran 943928
895 Asiatic jackal Japan
896 Cat, civet Japan 929056
897 Giant anteater Lebanon
898 Steller sea lion Indonesia 199894
899 Short-nosed bandicoot Serbia 974372
900 Bat, asian false vampire China 363292
901 Crab-eating fox Indonesia 809834
902 Zorilla Sweden 50138
903 Sugar glider Cuba 105667
904 Leopard Indonesia 918880
905 Creeper, black-tailed tree Canada 410272
Golden-mantled ground squirrel Russia 123972
907 Clark's nutcracker Russia 888405
908 Tsessebe Sweden 24554
909 Cape raven China 186044
910 Cormorant, great Armenia 116365
Wombat, common China 28097
912 Brown lemur China 134123
913 Indian peacock Japan 740572
Bird (unidentified) Japan 717915
915 Eagle, bald Indonesia 810634
916 Seven-banded armadillo Tanzania 329826
Collared lemming Portugal 195834
Common wolf Poland 877740
919 Hornbill, southern ground Philippines 281390
Skink, african Switzerland 784925
921 Golden eagle China 589879
922 Mule deer Russia 620403
923 Waxbill, violet-eared China 847046
Langur, gray China 528724
925 Egret, snowy Ukraine 575927
926 Black-backed jackal Sweden 367059
927 Duiker, gray Colombia 232384
928 Boa, emerald green tree China 394035
929 Giant anteater Portugal 265386
930 Wolf, timber China 250136
931 Goose, egyptian Uruguay 954434
932 Spotted deer Philippines 915146
933 Anaconda (unidentified) Yemen 329130
Thrasher, curve-billed Sweden 968754
935 Badger, european Indonesia 476736
936 Springhare Brazil 190952
937 Rat, desert kangaroo Russia
938 Brush-tailed rat kangaroo France 60050
939 Bushbuck Brazil 475747
940 Huron Morocco 178298
Elephant, asian China 829802
942 Spectacled caiman Philippines
943 Darwin ground finch (unidentified) Mexico 83781
944 North American red fox Kazakhstan 218186
945 Monkey, bleeding heart Argentina 907986
946 Tamandua, southern Colombia
947 Cormorant, flightless Indonesia 881944
948 Drongo, fork-tailed Indonesia 500387
949 White-tailed deer Indonesia 771439
950 Openbill, asian Czech Republic
951 Nutcracker, clark's Indonesia
952 Rattlesnake, horned United States 89106
953 Tortoise, radiated Philippines 616993
954 Black kite Malaysia 958000
955 Striped skunk China 331868
956 Hummingbird (unidentified) Brazil 332861
957 Swan, black Philippines 198579
958 Siskin, pine Indonesia 899861
959 Red-billed buffalo weaver China 147730
960 Lesser flamingo Poland 423339
961 Frilled dragon Egypt 162848
962 Malachite kingfisher Thailand 651922
963 Sandpiper, spotted wood Mongolia 29561
964 Raccoon dog Indonesia 667669
965 Chipmunk, least Indonesia 490586
966 Fairy penguin Thailand
967 Denham's bustard Bosnia and Herzegovina 559546
968 Stork, openbill Indonesia
969 Deer, spotted China 424216
970 Plains zebra Mexico 528420
971 Raccoon, crab-eating Portugal 376501
Laughing kookaburra Nigeria 471679
973 Crane, sarus Samoa 634377
974 Seal, southern elephant Russia 935739
975 North American porcupine South Africa 478583
Desert kangaroo rat United States 167362
977 Eagle, golden Russia 954923
978 Bohor reedbuck Poland
Bush dog Denmark 196850
980 Common zebra Portugal 432400
981 Australian pelican China 22915
982 Vulture, egyptian United States 142155
983 Violet-crested turaco China 985562
Ringtail Bolivia
985 Aardwolf Croatia 552574
986 Bird (unidentified) Portugal 631642
987 Little cormorant Vietnam 912531
988 Bushbaby, large-eared Comoros 974687
989 Four-striped grass mouse Ireland 980269
990 Galapagos penguin Pakistan 699287
Loris, slender Philippines 8821
992 Gull, southern black-backed Philippines 224813
993 Mexican beaded lizard China 754860
994 Squirrel, arctic ground Palestinian Territory
Genet, common Luxembourg 263819
996 Common mynah China 915339
997 Blue racer China 930725
998 Stanley crane Indonesia
999 Cormorant, king Russia 991115
1000 Hawk-eagle, crowned Argentina 376715
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment