Mercurial > repos > jjohnson > query_tabular
comparison query_tabular.xml @ 14:3003fe70f297 draft
Uploaded
| author | jjohnson |
|---|---|
| date | Fri, 09 Jun 2017 11:24:56 -0400 |
| parents | fd16243931d6 |
| children | 5b4f6cf857cf |
comparison
equal
deleted
inserted
replaced
| 13:49ca06d66762 | 14:3003fe70f297 |
|---|---|
| 511 1 Steven Jones 1974-04-04 Allie cat 4 2 3 | 511 1 Steven Jones 1974-04-04 Allie cat 4 2 3 |
| 512 0 Jane Doe 1978-05-24 5 3 4 | 512 0 Jane Doe 1978-05-24 5 3 4 |
| 513 1 James Smith 1980-10-20 Spot 6 4 5 | 513 1 James Smith 1980-10-20 Spot 6 4 5 |
| 514 | 514 |
| 515 | 515 |
| 516 Table name: pets | 516 Table name: pets |
| 517 | 517 |
| 518 Table columns: Pets,FirstName,LastName,Birthdate,PetNames,PetType,line_num,entry_num,row_num | 518 Table columns: Pets,FirstName,LastName,Birthdate,PetNames,PetType,line_num,entry_num,row_num |
| 519 | 519 |
| 520 Query: SELECT * FROM pets | 520 Query: SELECT * FROM pets |
| 521 | 521 |
| 522 Result: | 522 Result: |
| 523 | 523 |
| 524 ===== ========= ======== ========== ======== ======= ======== ========= ======= | 524 ====== ========== ======== ========== ========= ======== ========= ========== ======== |
| 525 #Pets FirstName LastName Brithdate PetNames PetType line_num entry_num row_num | 525 #Pets FirstName LastName BirthDate PetNames PetType line_num entry_num row_num |
| 526 ===== ========= ======== ========== ======== ======= ======== ========= ======= | 526 ====== ========== ======== ========== ========= ======== ========= ========== ======== |
| 527 2 Paula Brown 1978-05-24 Rex dog 3 1 1 | 527 2 Paula Brown 1978-05-24 Rex dog 3 1 1 |
| 528 2 Paula Brown 1978-05-24 Fluff cat 3 1 2 | 528 2 Paula Brown 1978-05-24 Fluff cat 3 1 2 |
| 529 1 Steven Jones 1974-04-04 Allie cat 4 2 3 | 529 1 Steven Jones 1974-04-04 Allie cat 4 2 3 |
| 530 0 Jane Doe 1978-05-24 5 3 4 | 530 0 Jane Doe 1978-05-24 5 3 4 |
| 531 1 James Smith 1980-10-20 Spot 6 4 5 | 531 1 James Smith 1980-10-20 Spot 6 4 5 |
| 532 ===== ========= ======== ========== ======== ======= ======== ========= ======= | 532 ====== ========== ======== ========== ========= ======== ========= ========== ======== |
| 533 | 533 |
| 534 | |
| 535 **Normalizing by Line Filtering into 2 Tables** | |
| 536 | |
| 537 *People Table* | |
| 538 | |
| 539 :: | |
| 540 | |
| 541 Filter 1 - by regex expression matching [include]: '^\d+' (include lines that start with a number) | |
| 542 Filter 2 - append a line number column: | |
| 543 Filter 3 - regex replace value in column[4]: '(\d+)/(\d+)/(\d+)' '19\3-\2-\1' (convert dates to sqlite format) | |
| 544 | |
| 545 Table: People | |
| 546 Columns: Pets,FirstName,LastName,DOB,,,id | |
| 547 | |
| 548 ==== ========= ======== ========== == | |
| 549 Pets FirstName LastName DOB id | |
| 550 ==== ========= ======== ========== == | |
| 551 2 Paula Brown 1978-05-24 1 | |
| 552 1 Steven Jones 1974-04-04 2 | |
| 553 0 Jane Doe 1978-05-24 3 | |
| 554 1 James Smith 1980-10-20 4 | |
| 555 ==== ========= ======== ========== == | |
| 556 | |
| 557 | |
| 558 *Pet Table* | |
| 559 | |
| 560 :: | |
| 561 | |
| 562 Filter 1 - by regex expression matching [include]: '^\d+' (include lines that start with a number) | |
| 563 Filter 2 - append a line number column: | |
| 564 Filter 3 - by regex expression matching [exclude]: '^0\t' (exclude lines with no pets) | |
| 565 Filter 4 - normalize list columns[5,6]: | |
| 566 | |
| 567 Table: Pet | |
| 568 Columns: ,,,,PetName,PetType,id | |
| 569 | |
| 570 ======== ======== == | |
| 571 PetName PetType id | |
| 572 ======== ======== == | |
| 573 Rex dog 1 | |
| 574 Fluff cat 1 | |
| 575 Allie cat 2 | |
| 576 Spot 4 | |
| 577 ======== ======== == | |
| 578 | |
| 579 | |
| 580 Query: SELECT FirstName,LastName,PetName FROM People join Pet on People.id = Pet.id WHERE PetType = 'cat'; | |
| 581 | |
| 582 Result: | |
| 583 | |
| 584 ========= ======== ======== | |
| 585 FirstName LastName PetName | |
| 586 ========= ======== ======== | |
| 587 Paula Brown Fluff | |
| 588 Steven Jones Allie | |
| 589 ========= ======== ======== | |
| 534 | 590 |
| 535 .. _Regular_expression: https://docs.python.org/release/2.7/library/re.html | 591 .. _Regular_expression: https://docs.python.org/release/2.7/library/re.html |
| 536 .. _SQLite: http://www.sqlite.org/index.html | 592 .. _SQLite: http://www.sqlite.org/index.html |
| 537 | 593 |
| 538 ]]></help> | 594 ]]></help> |
