andrea.nieves7 1 year ago
parent
commit
a274a3ff5c
4 changed files with 103 additions and 25 deletions
  1. 12
    25
      App.js
  2. 66
    0
      package-lock.json
  3. 1
    0
      package.json
  4. 24
    0
      yarn.lock

+ 12
- 25
App.js View File

@@ -2,6 +2,8 @@ import { StatusBar } from 'expo-status-bar';
2 2
 import React, {useState, useEffect} from 'react';
3 3
 import { View, Image, StyleSheet, Text, Button, ScrollView, Pressable} from 'react-native';
4 4
 import DropDownPicker from 'react-native-dropdown-picker';
5
+import { parse } from 'json2csv';
6
+
5 7
 //import JSON;
6 8
 //import { Dataframe, readJSON } from "danfojs";
7 9
 
@@ -17,32 +19,17 @@ var information = "data goes here"
17 19
 
18 20
 function organize(){
19 21
 	
20
-	var stringDiv = JSON.stringify(information)
21
-	stringDiv = stringDiv.replace('[[', '');
22
-	stringDiv = stringDiv.replace(']]', '');
23
-	stringDiv = stringDiv.split(',')
24
-	//create smaller array variables
25
-	let variables = []
26
-	let value = []
27
-	let est = []
28
-	
29
-	
30
-	//theres a better way to do this but im not fixing it rn
31
-	for(let i = 0; i<stringDiv.length; i++){
32
-		if(i<stringDiv.length/3)
33
-		{variables.push(stringDiv[i])}
34
-		else if(i<stringDiv.length/3*2)
35
-		{value.push(stringDiv[i])}
36
-		else{est.push(stringDiv[i])}
37
-	}
38
-	
39
-	//anyways this to format it
22
+	var stringDiv = JSON.parse(information)
23
+	var csv = parse(stringDiv)
24
+	console.log(csv)
40 25
 	
41
-	console.log("vars:",variables)
42
-	console.log("val:",value)
43
-	console.log("est:",est)
44
-	//organizedData = JSON.parse(information)
45
-	//console.log(stringDiv)
26
+	//var csv is the variable with the thing you just pulled
27
+	//put function and data cleaning here
28
+	//just make sure you change the return value in 'getInfo()'
29
+	//so it returns the actual organized table
30
+	//or make getInfo() organize the table as well
31
+	//and return that organized table
32
+	//i leave this to you
46 33
 	
47 34
 }
48 35
 

+ 66
- 0
package-lock.json View File

@@ -15,6 +15,7 @@
15 15
         "expo-font": "~11.0.1",
16 16
         "expo-splash-screen": "~0.17.5",
17 17
         "expo-status-bar": "~1.4.2",
18
+        "json2csv": "^5.0.7",
18 19
         "react": "18.1.0",
19 20
         "react-dom": "18.1.0",
20 21
         "react-native": "0.70.5",
@@ -11668,6 +11669,31 @@
11668 11669
       "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
11669 11670
       "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg=="
11670 11671
     },
11672
+    "node_modules/json2csv": {
11673
+      "version": "5.0.7",
11674
+      "resolved": "https://registry.npmjs.org/json2csv/-/json2csv-5.0.7.tgz",
11675
+      "integrity": "sha512-YRZbUnyaJZLZUJSRi2G/MqahCyRv9n/ds+4oIetjDF3jWQA7AG7iSeKTiZiCNqtMZM7HDyt0e/W6lEnoGEmMGA==",
11676
+      "dependencies": {
11677
+        "commander": "^6.1.0",
11678
+        "jsonparse": "^1.3.1",
11679
+        "lodash.get": "^4.4.2"
11680
+      },
11681
+      "bin": {
11682
+        "json2csv": "bin/json2csv.js"
11683
+      },
11684
+      "engines": {
11685
+        "node": ">= 10",
11686
+        "npm": ">= 6.13.0"
11687
+      }
11688
+    },
11689
+    "node_modules/json2csv/node_modules/commander": {
11690
+      "version": "6.2.1",
11691
+      "resolved": "https://registry.npmjs.org/commander/-/commander-6.2.1.tgz",
11692
+      "integrity": "sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA==",
11693
+      "engines": {
11694
+        "node": ">= 6"
11695
+      }
11696
+    },
11671 11697
     "node_modules/json3": {
11672 11698
       "version": "3.3.3",
11673 11699
       "resolved": "https://registry.npmjs.org/json3/-/json3-3.3.3.tgz",
@@ -11697,6 +11723,14 @@
11697 11723
         "graceful-fs": "^4.1.6"
11698 11724
       }
11699 11725
     },
11726
+    "node_modules/jsonparse": {
11727
+      "version": "1.3.1",
11728
+      "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz",
11729
+      "integrity": "sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg==",
11730
+      "engines": [
11731
+        "node >= 0.2.0"
11732
+      ]
11733
+    },
11700 11734
     "node_modules/killable": {
11701 11735
       "version": "1.0.1",
11702 11736
       "resolved": "https://registry.npmjs.org/killable/-/killable-1.0.1.tgz",
@@ -11818,6 +11852,11 @@
11818 11852
       "integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==",
11819 11853
       "license": "MIT"
11820 11854
     },
11855
+    "node_modules/lodash.get": {
11856
+      "version": "4.4.2",
11857
+      "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz",
11858
+      "integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ=="
11859
+    },
11821 11860
     "node_modules/lodash.memoize": {
11822 11861
       "version": "4.1.2",
11823 11862
       "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz",
@@ -28854,6 +28893,23 @@
28854 28893
       "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz",
28855 28894
       "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg=="
28856 28895
     },
28896
+    "json2csv": {
28897
+      "version": "5.0.7",
28898
+      "resolved": "https://registry.npmjs.org/json2csv/-/json2csv-5.0.7.tgz",
28899
+      "integrity": "sha512-YRZbUnyaJZLZUJSRi2G/MqahCyRv9n/ds+4oIetjDF3jWQA7AG7iSeKTiZiCNqtMZM7HDyt0e/W6lEnoGEmMGA==",
28900
+      "requires": {
28901
+        "commander": "^6.1.0",
28902
+        "jsonparse": "^1.3.1",
28903
+        "lodash.get": "^4.4.2"
28904
+      },
28905
+      "dependencies": {
28906
+        "commander": {
28907
+          "version": "6.2.1",
28908
+          "resolved": "https://registry.npmjs.org/commander/-/commander-6.2.1.tgz",
28909
+          "integrity": "sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA=="
28910
+        }
28911
+      }
28912
+    },
28857 28913
     "json3": {
28858 28914
       "version": "3.3.3",
28859 28915
       "resolved": "https://registry.npmjs.org/json3/-/json3-3.3.3.tgz",
@@ -28873,6 +28929,11 @@
28873 28929
         "universalify": "^2.0.0"
28874 28930
       }
28875 28931
     },
28932
+    "jsonparse": {
28933
+      "version": "1.3.1",
28934
+      "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz",
28935
+      "integrity": "sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg=="
28936
+    },
28876 28937
     "killable": {
28877 28938
       "version": "1.0.1",
28878 28939
       "resolved": "https://registry.npmjs.org/killable/-/killable-1.0.1.tgz",
@@ -28962,6 +29023,11 @@
28962 29023
       "resolved": "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz",
28963 29024
       "integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow=="
28964 29025
     },
29026
+    "lodash.get": {
29027
+      "version": "4.4.2",
29028
+      "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz",
29029
+      "integrity": "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ=="
29030
+    },
28965 29031
     "lodash.memoize": {
28966 29032
       "version": "4.1.2",
28967 29033
       "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz",

+ 1
- 0
package.json View File

@@ -16,6 +16,7 @@
16 16
     "expo-font": "~11.0.1",
17 17
     "expo-splash-screen": "~0.17.5",
18 18
     "expo-status-bar": "~1.4.2",
19
+    "json2csv": "^5.0.7",
19 20
     "react": "18.1.0",
20 21
     "react-dom": "18.1.0",
21 22
     "react-native": "0.70.5",

+ 24
- 0
yarn.lock View File

@@ -3568,6 +3568,11 @@
3568 3568
   "resolved" "https://registry.npmjs.org/commander/-/commander-5.1.0.tgz"
3569 3569
   "version" "5.1.0"
3570 3570
 
3571
+"commander@^6.1.0":
3572
+  "integrity" "sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA=="
3573
+  "resolved" "https://registry.npmjs.org/commander/-/commander-6.2.1.tgz"
3574
+  "version" "6.2.1"
3575
+
3571 3576
 "commander@^7.2.0":
3572 3577
   "integrity" "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw=="
3573 3578
   "resolved" "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz"
@@ -6653,6 +6658,15 @@
6653 6658
   "resolved" "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz"
6654 6659
   "version" "1.0.0"
6655 6660
 
6661
+"json2csv@^5.0.7":
6662
+  "integrity" "sha512-YRZbUnyaJZLZUJSRi2G/MqahCyRv9n/ds+4oIetjDF3jWQA7AG7iSeKTiZiCNqtMZM7HDyt0e/W6lEnoGEmMGA=="
6663
+  "resolved" "https://registry.npmjs.org/json2csv/-/json2csv-5.0.7.tgz"
6664
+  "version" "5.0.7"
6665
+  dependencies:
6666
+    "commander" "^6.1.0"
6667
+    "jsonparse" "^1.3.1"
6668
+    "lodash.get" "^4.4.2"
6669
+
6656 6670
 "json3@^3.3.2":
6657 6671
   "integrity" "sha512-c7/8mbUsKigAbLkD5B010BK4D9LZm7A1pNItkEwiUZRpIN66exu/e7YQWysGun+TRKaJp8MhemM+VkfWv42aCA=="
6658 6672
   "resolved" "https://registry.npmjs.org/json3/-/json3-3.3.3.tgz"
@@ -6698,6 +6712,11 @@
6698 6712
   optionalDependencies:
6699 6713
     "graceful-fs" "^4.1.6"
6700 6714
 
6715
+"jsonparse@^1.3.1":
6716
+  "integrity" "sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg=="
6717
+  "resolved" "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz"
6718
+  "version" "1.3.1"
6719
+
6701 6720
 "killable@^1.0.1":
6702 6721
   "integrity" "sha512-LzqtLKlUwirEUyl/nicirVmNiPvYs7l5n8wOPP7fyJVpUPkvCnW/vuiXGpylGUlnPDnB7311rARzAt3Mhswpjg=="
6703 6722
   "resolved" "https://registry.npmjs.org/killable/-/killable-1.0.1.tgz"
@@ -6861,6 +6880,11 @@
6861 6880
   "resolved" "https://registry.npmjs.org/lodash.debounce/-/lodash.debounce-4.0.8.tgz"
6862 6881
   "version" "4.0.8"
6863 6882
 
6883
+"lodash.get@^4.4.2":
6884
+  "integrity" "sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ=="
6885
+  "resolved" "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz"
6886
+  "version" "4.4.2"
6887
+
6864 6888
 "lodash.memoize@^4.1.2":
6865 6889
   "integrity" "sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag=="
6866 6890
   "resolved" "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz"