Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

asciirowselect.sh 1.9 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
  1. #!/usr/bin/env bash
  2. # Test gmt convert with ascii data and using -qi
  3. # Build two ascii files
  4. echo "> Seg 1 File 1" > one.txt
  5. gmt math -T2010-12-01T/2010-12-31T/1d TROW = >> one.txt
  6. echo "> Seg 2 File 1" >> one.txt
  7. gmt math -T2011-01-01T/2011-01-311T/1d TROW 100 ADD = >> one.txt
  8. echo "> Seg 1 File 2" > two.txt
  9. gmt math -T2011-02-01T/2011-02-28T/1d TROW 200 ADD = >> two.txt
  10. echo "> Seg 2 File 2" >> two.txt
  11. gmt math -T2011-03-01T/2011-03-31T/1d TROW 100 ADD = >> two.txt
  12. # Case 1: Only pull two first data records per segment
  13. gmt convert one.txt two.txt -q:1+s > answer1.txt
  14. # This is what the first output should look like
  15. cat << EOF > truth1.txt
  16. > Seg 1 File 1
  17. 2010-12-01T00:00:00 0
  18. 2010-12-02T00:00:00 1
  19. > Seg 2 File 1
  20. 2011-01-01T00:00:00 100
  21. 2011-01-02T00:00:00 101
  22. > Seg 1 File 2
  23. 2011-02-01T00:00:00 200
  24. 2011-02-02T00:00:00 201
  25. > Seg 2 File 2
  26. 2011-03-01T00:00:00 100
  27. 2011-03-02T00:00:00 101
  28. EOF
  29. diff truth1.txt answer1.txt --strip-trailing-cr > fail
  30. # Case 2: Same, but per file
  31. gmt convert one.txt two.txt -q:1+f > answer2.txt
  32. # This is what the first output should look like
  33. cat << EOF > truth2.txt
  34. > Seg 1 File 1
  35. 2010-12-01T00:00:00 0
  36. > Seg 1 File 2
  37. 2011-02-01T00:00:00 200
  38. EOF
  39. diff truth2.txt answer2.txt --strip-trailing-cr >> fail
  40. # Case 3: Limit to just Dec 30-Jan 2 inclusive
  41. gmt convert one.txt two.txt -q2010-12-30T/2011-01-02T+c0 > answer3.txt
  42. cat << EOF > truth3.txt
  43. > Seg 1 File 1
  44. 2010-12-30T00:00:00 29
  45. 2010-12-31T00:00:00 30
  46. > Seg 2 File 1
  47. 2011-01-01T00:00:00 100
  48. 2011-01-02T00:00:00 101
  49. EOF
  50. diff truth3.txt answer3.txt --strip-trailing-cr >> fail
  51. # Case 4: Exclude rows with data values
  52. gmt convert one.txt two.txt -q~200-400,0-127+c1 > answer4.txt
  53. cat << EOF > truth4.txt
  54. > Seg 2 File 1
  55. 2011-01-29T00:00:00 128
  56. 2011-01-30T00:00:00 129
  57. 2011-01-31T00:00:00 130
  58. > Seg 2 File 2
  59. 2011-03-29T00:00:00 128
  60. 2011-03-30T00:00:00 129
  61. 2011-03-31T00:00:00 130
  62. EOF
  63. diff truth4.txt answer4.txt --strip-trailing-cr >> fail
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...