Comments (8)
I'm working on it.
This is what it looks like at this point, mostly as proof of concept that it actually does work:
>trade olddata --raw
('table', [('Station', 'DistLy', 'Age/days', 'StnLs', 'Pad', 'Plt', 'Flc'), ('Chih Hiner/Soukup Town', 0.0, 708.4715489004739, '15', 'Lrg', 'Yes', 'No'), ('HIP 4073/Herbig Settlement', 0.0, 708.0695002893917, '3.34K', 'Lrg', 'Yes', 'No'), ('Segovas/Thollon Works', 0.0, 708.0026831598952, '822', 'Lrg', 'Yes', 'No'), ("HIP 109642/Mayor's Claim", 0.0, 700.1933544562198, '3.17K', 'Med', 'No', 'No'), ('Col 285 Sector SE-Q d5-134/Baker Arena', 0.0, 684.7466067709029, '3.20K', 'Lrg', 'Yes', 'No'), ('Volupana/Vercors Prospect', 0.0, 682.8277063081041, '235', 'Lrg', 'Yes', 'No'), ('HIP 16272/Stone Port', 0.0, 677.6948475115933, '3.60K', 'Med', 'No', 'No'), ('HIP 862/Carpenter Keep', 0.0, 674.8596623265184, '1.41K', 'Lrg', 'Yes', 'No'), ('Ambibarii/Steinmuller Camp', 0.0, 669.7662826972082, '2.18K', 'Lrg', 'Yes', 'No'), ('Kremovi/Brothers Settlement', 0.0, 660.9491067710333, '464K', 'Lrg', 'Yes', 'No'), ('Jurasmat/Brooks Plant', 0.0, 659.001433160156, '26', 'Lrg', 'Yes', 'No'), ('Ekoimudji/Coppel Beacon', 0.0, 651.8908776044846, '35', 'Lrg', 'Yes', 'No'), ('Quile/Messerschmitt Point', 0.0, 647.3532965858467, '110', 'Lrg', 'Yes', 'No'), ('Arevat/Gaultier de Varennes Relay', 0.0, 646.7622664934024, '482', 'Lrg', 'Yes', 'No'), ('Tricasses/Banks Landing', 0.0, 638.9739331598394, '288', 'Lrg', 'Yes', 'No'), ('Dinde/Youll Penal colony', 0.0, 637.8445002897643, '33K', 'Lrg', 'Yes', 'No'), ('Ten Gu/Kummer Observatory', 0.0, 636.7051947340369, '403', 'Lrg', 'Yes', 'No'), ('Uzumoku/Noguchi Base', 0.0, 629.7080882526934, '505K', 'Lrg', 'Yes', 'No'), ('Naporimui/Hewish Mines', 0.0, 622.6532965856604, '17K', 'Med', 'No', 'No'), ('HIP 2725/Marques Keep', 0.0, 622.6404840857722, '60', 'Lrg', 'Yes', 'No')])
>trade olddata
Station Age/days StnLs Pad Plt Flc
----------------------------------------------------------------------
Chih Hiner/Soukup Town 708.47 15 Lrg Yes No
HIP 4073/Herbig Settlement 708.07 3.34K Lrg Yes No
Segovas/Thollon Works 708.00 822 Lrg Yes No
HIP 109642/Mayor's Claim 700.19 3.17K Med No No
Col 285 Sector SE-Q d5-134/Baker Arena 684.75 3.20K Lrg Yes No
Volupana/Vercors Prospect 682.83 235 Lrg Yes No
HIP 16272/Stone Port 677.69 3.60K Med No No
HIP 862/Carpenter Keep 674.86 1.41K Lrg Yes No
Ambibarii/Steinmuller Camp 669.77 2.18K Lrg Yes No
Kremovi/Brothers Settlement 660.95 464K Lrg Yes No
Jurasmat/Brooks Plant 659.00 26 Lrg Yes No
Ekoimudji/Coppel Beacon 651.89 35 Lrg Yes No
Quile/Messerschmitt Point 647.35 110 Lrg Yes No
Arevat/Gaultier de Varennes Relay 646.76 482 Lrg Yes No
Tricasses/Banks Landing 638.97 288 Lrg Yes No
Dinde/Youll Penal colony 637.84 33K Lrg Yes No
Ten Gu/Kummer Observatory 636.70 403 Lrg Yes No
Uzumoku/Noguchi Base 629.71 505K Lrg Yes No
Naporimui/Hewish Mines 622.65 17K Med No No
HIP 2725/Marques Keep 622.64 60 Lrg Yes No
from trade-dangerous.
Regardless of which command(s) you want to get json for, the best option is to trace the code to the point where it's about to pass a big list of results (which helpfully is usually if not always called "results") to something that does output formatting, and sending that list of results to a json formatter instead when some cmd parameter is passed.
IIRC, python objects in general can be directly converted to json, and dict objects definitely can, so the json output formatter could probably be as simple as:
- Convert result list to json using python's native converter.
- Print the conversion to stdout or a file.
- ????
- Profit.
from trade-dangerous.
I'm not certain what output you're referring to, but if you post an example with the current output and the same information in the desired json format, I can look into when I have time.
Also, don't be afraid to code it yourself. It's pretty likely you'd have it coded more quickly than I, and 90% of programming is fixing the bugs found during testing, anyway.
from trade-dangerous.
Thanks @eyeonus - I'm trying to get programatic access to the results of trade queries via Javascript.
At the moment I'm executing a python process from Node.js and capturing output like...
Station Cost Units Age/days StnLs B/mkt Pad Plt
-------------------------------------------------------------------------------------------------
Hahgwe/Barcelos Camp 4,539 0 0.50 321 No Lrg Yes
Ross 665/Malpighi Oasis 4,539 0 24.28 1.50K No Lrg Yes
For now I just hacked in a distinct |
separator between columns so I can parse it back into an object using regex. To be universally portable without those workarounds, I was hoping to get JSON values in their original types (not formatted for readable display). Something like:
{
"results": [
{
"Station": "Hahgwe/Barcelos Camp",
"Cost": 4539,
"Units": 0,
"Age/days": 0.50,
"StnLs": 321,
"B/mkt": false,
"Pad": "Lrg",
"Plt": true
},
{
"Station": "Ross 665/Malpighi Oasis",
"Cost": 4539,
"Units": 0,
"Age/days": 24.28,
"StnLs": 150000,
"B/mkt": false,
"Pad": "Lrg",
"Plt": true
}
]
}
I had a look at coding myself, but I can't get my head around where to divert the logic producing the result set columns. e.g. in formatting.py
or higher at the nav_cmd.py
level?
from trade-dangerous.
It depends on which output you want to redirect.
For example, to redirect the output from the "trade" command, you would want to modify the "render" method in the "commands/trade.py" module.
(Or, alternatively, figure out where that particular method gets called, build a different json render method, and have the calling program call the json render instead when the json option is enabled.)
from trade-dangerous.
FYI, I never learned much Python and couldn't figure out how to convert results. Instead I wrote some helpers to read the printed results and convert back into objects in Javascript. Not ideal, but it works for my immediate needs. If anyone asks I can share back here, but it's not in a state to make public yet.
from trade-dangerous.
Oops didn't mean to close. This would still be a nice to have, so I'll reopen in the event someone with the required skill can pick it up.
from trade-dangerous.
Closing. Ancient, not been touched in years and we are making moves away from prices anywa6.
from trade-dangerous.
Related Issues (20)
- Executing a trade run after a database update gives an error. In my TD\data folder the Tradedangerous.prices file is not showing HOT 6
- Fix the need to generate prices - pretty please with sugar on top. HOT 16
- When I run the command "trade.py import -P eddblink -O all", I get error messages ! HOT 9
- A General List of Potential Issues
- Fix warnings in deploy HOT 4
- Server hosting upgrade HOT 53
- Locale changes break on systems with certain locales, in general unnecessary
- Looks like `--progress` no longer works HOT 1
- Function/command "Cmdr Profile" generates an error HOT 4
- The search for specific goods generates an error ! Function "buy" HOT 10
- Again a problem with the command/function "Cmdr Profile" HOT 5
- The Culling: What's deprecated/discontinued?
- Enable Discussions tab in Github?
- PadSize argument parser is explicitly only allowing one character HOT 3
- Duplicate Rescue Ship "HR 1183/Arc's Faith" HOT 1
- The server seems to be no longer updating. HOT 11
- Could you add option to filter out Fleet Carriers HOT 1
- `trade.py trade` definitely does more work than it should HOT 7
- SQL error on first re-import of `eddblink` HOT 2
- Database / needed file size optimisations HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from trade-dangerous.