I am currently writing an Disassembler, now I want to create new strings, like that:
// Disassembler Sourcefile
// better known as DisAsm
#include "disassembler.h"
#include <QString>
Disassembler::Disassembler()
{
QString *_protos = new QString[] { "NOP",
"LD BC,d16",
"LD (BC),A",
"INC BC",
"INC B",
"DEC B",
"LD B,d8",
"RLCA",
"LD (a16),SP",
"ADD HL,BC",
"LD A,(BC)",
"DEC BC",
"INC C",
"DEC C",
"LD C,d8",
"RRCA",
"STOP 0",
"LD DE,d16",
"LD (DE),A",
"INC DE",
"INC D",
"DEC D",
"LD D,d8",
"RLA",
"JR r8",
"ADD HL,DE",
"LD A,(DE)",
"DEC DE",
"INC E",
"DEC E",
"LD E,d8",
"RRA",
"JR NZ,r8",
"LD HL,d16",
"LD (HL+),A",
"INC HL",
"INC H",
"DEC H",
"LD H,d8",
"DAA",
"JR Z,r8",
"ADD HL,HL",
"LD A,(HL+)",
"DEC HL",
"INC L",
"DEC L",
"LD L,d8",
"CPL",
"JR NC,r8",
"LD SP,d16",
"LD (HL-),A",
"INC SP",
"INC (HL)",
"DEC (HL)",
"LD (HL),d8",
"SCF",
"JR C,r8",
"ADD HL,SP",
"LD A,(HL-)",
"DEC SP",
"INC A",
"DEC A",
"LD A,d8",
"CCF",
"LD B,B",
"LD B,C",
"LD B,D",
"LD B,E",
"LD B,H",
"LD B,L",
"LD B,(HL)",
"LD B,A",
"LD C,B",
"LD C,C",
"LD C,D",
"LD C,E",
"LD C,H",
"LD C,L",
"LD C,(HL)",
"LD C,A",
"LD D,B",
"LD D,C",
"LD D,D",
"LD D,E",
"LD D,H",
"LD D,L",
"LD D,(HL)",
"LD D,A",
"LD E,B",
"LD E,C",
"LD E,D",
"LD E,E",
"LD E,H",
"LD E,L",
"LD E,(HL)",
"LD E,A",
"LD H,B",
"LD H,C",
"LD H,D",
"LD H,E",
"LD H,H",
"LD H,L",
"LD H,(HL)",
"LD H,A",
"LD L,B",
"LD L,C",
"LD L,D",
"LD L,E",
"LD L,H",
"LD L,L",
"LD L,(HL)",
"LD L,A",
"LD (HL),B",
"LD (HL),C",
"LD (HL),D",
"LD (HL),E",
"LD (HL),H",
"LD (HL),L",
"HALT",
"LD (HL),A",
"LD A,B",
"LD A,C",
"LD A,D",
"LD A,E",
"LD A,H",
"LD A,L",
"LD A,(HL)",
"LD A,A",
"ADD A,B",
"ADD A,C",
"ADD A,D",
"ADD A,E",
"ADD A,H",
"ADD A,L",
"ADD A,(HL)",
"ADD A,A",
"ADC A,B",
"ADC A,C",
"ADC A,D",
"ADC A,E",
"ADC A,H",
"ADC A,L",
"ADC A,(HL)",
"ADC A,A",
"SUB B",
"SUB C",
"SUB D",
"SUB E",
"SUB H",
"SUB L",
"SUB (HL)",
"SUB A",
"SBC A,B",
"SBC A,C",
"SBC A,D",
"SBC A,E",
"SBC A,H",
"SBC A,L",
"SBC A,(HL)",
"SBC A,A",
"AND B",
"AND C",
"AND D",
"AND E",
"AND H",
"AND L",
"AND (HL)",
"AND A",
"XOR B",
"XOR C",
"XOR D",
"XOR E",
"XOR H",
"XOR L",
"XOR (HL)",
"XOR A",
"OR B",
"OR C",
"OR D",
"OR E",
"OR H",
"OR L",
"OR (HL)",
"OR A",
"CP B",
"CP C",
"CP D",
"CP E",
"CP H",
"CP L",
"CP (HL)",
"CP A",
"RET NZ",
"POP BC",
"JP NZ,a16",
"JP a16",
"CALL NZ,a16",
"PUSH BC",
"ADD A,d8",
"RST 00H",
"RET Z",
"RET",
"JP Z,a16",
"PREFIX CB",
"CALL Z,a16",
"CALL a16",
"ADC A,d8",
"RST 08H",
"RET NC",
"POP DE",
"JP NC,a16",
"???",
"CALL NC,a16",
"PUSH DE",
"SUB d8",
"RST 10H",
"RET C",
"RETI",
"JP C,a16",
"???",
"CALL C,a16",
"???",
"SBC A,d8",
"RST 18H",
"LDH (a8),A",
"POP HL",
"LD (C),A",
"???",
"???",
"PUSH HL",
"AND d8",
"RST 20H",
"ADD SP,r8",
"JP HL",
"LD (a16),A",
"???",
"???",
"???",
"XOR d8",
"RST 28H",
"LDH A,(a8)",
"POP AF",
"LD A,(C)",
"DI",
"???",
"PUSH AF",
"OR d8",
"RST 30H",
"LD HL,SP+r8",
"LD SP,HL",
"LD A,(a16)",
"EI",
"???",
"???",
"CP d8",
"RST 38H" };
}
But now I get an error in the last line/line 256 (means the last line of the complete file).
C:\Users\Jan\Desktop\GB Emulator\gbx00\disassembler.cpp:265: Error: C1001: An internal error has occurred in the compiler.
I have tried to replace the "};" with only an "}" but this didn't works to. How can I fix this?
NOTE: I'll try to translate an C# code into C++/Qt.
If you need to create an array of QStrings it should be:
QString _protos[] = { "NOP",
"LD BC,d16",
"LD (BC),A",
...
"RST 38H" };
instead.
Related
For the context: For downloading DHS data I follow this link: https://rspatialdata.github.io/dhs-data.html#Loading_datasets_and_associating_its_metadata_into_R
I want to analyze it following this post: https://github.com/DHSProgram/DHS-Indicators-R/commit/1c64b0f2af33ac56d149a7dbce34ea8bb21ce3f9
Since I have data from 5 countries, starting in 2000 I joined HW files to PR files, where the orginal PR files did't have the hc (undernourishment) variables. The merge of HW files to PR files ended up the comb_extract_HW_res dataframe. However, when I want to bind my comb_extract_HW_res to the other dataframes (which files already included the hc variables) comb_extract by rbin_labelled (as I did for example to create comb_extact and everything just worked fine). But in this step (combining comb_extract which already contained hc variables and comb_extract_HW_res, where I added the variables) I somehow loosing all my negative values of my hc variables. Someone have an idea how this happens?
comb_extract_all <- rbind_labelled(list(comb_extract, comb_extract_HW_res), labels = list(hv023 ="concatenate", hv024 = "concatenate", hc70 = "concatenate", hc71 = "concatenate", hc72 = "concatenate", hc73 = "concatenate"))
my two dfs are:
dput(comb_extract[1:3,1:10])
structure(list(hhid = c(" 1 27", " 1 27", " 1 27"
), hv001 = c(1, 1, 1), hv002 = c(27, 27, 27), hv005 = c(1707326,
1707326, 1707326), hv006 = c(8, 8, 8), hv007 = c(2003, 2003,
2003), hv021 = c(1, 1, 1), hv023 = structure(c(34L, 34L, 34L), labels = structure(1:343, names = c("1",
"10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "2",
"20", "21", "22", "23", "24", "25", "3", "4", "5", "6", "7",
"8", "9", "Acholi", "Addis Ababa", "Afar-rural", "Afar-Urban",
"Affar rural", "Affar urban", "Amhara-rural", "Amhara-urban",
"Amhara rural", "Amhara urban", "Ankole", "Balaka - rural", "Balaka - urban",
"Benishangul-Gumuz-rural", "Benishangul-Gumuz-urban", "Benishangul-Gumuz rural",
"Benishangul-Gumuz urban", "Blantyre - rural", "Blantyre - urban",
"Bomi - Rural", "Bomi - Urban", "Bomi Rural", "Bomi Urban", "Bong - Rural",
"Bong - Urban", "Bong Rural", "Bong Urban", "Bugesera", "Bugesera - rural",
"Bugesera - urban", "Bugisu", "Bukedi", "Bulawayo - Urban", "Bunyoro",
"Burera", "Burera - rural", "Burera - urban", "Busoga", "Central",
"Central 1", "Central 2", "Chikwawa - rural", "Chikwawa - urban",
"Chiradzulu - rural", "Chiradzulu - urban", "Chitipa - rural",
"Chitipa - urban", "Dedza - rural", "Dedza - urban", "Dire Dawa-urban",
"Dire Dawa -rural", "Dire Dawa rural", "Dire Dawa urban", "Dowa - rural",
"Dowa - urban", "East Central", "East Central Island-rural",
"Eastern", "Gakenke", "Gakenke - rural", "Gakenke - urban", "Gambela-rural",
"Gambela-urban", "Gambela rural", "Gambela urban", "Gasabo",
"Gasabo - rural", "Gasabo - urban", "Gatsibo", "Gatsibo - rural",
"Gatsibo - urban", "Gbarpolu - Rural", "Gbarpolu - Urban", "Gbarpolu Rural",
"Gbarpolu Urban", "Gicumbi", "Gicumbi - rural", "Gicumbi - urban",
"Gisagara", "Gisagara - rural", "Gisagara - urban", "Grand Bassa - Rural",
"Grand Bassa - Urban", "Grand Bassa Rural", "Grand Bassa Urban",
"Grand Cape Mount - Rural", "Grand Cape Mount - Urban", "Grand Cape Mount Rural",
"Grand Cape Mount Urban", "Grand Gedeh - Rural", "Grand Gedeh - Urban",
"Grand Gedeh Rural", "Grand Gedeh Urban", "Grand Kru - Rural",
"Grand Kru - Urban", "Grand Kru Rural", "Grand Kru Urban", "Harare - Urban",
"Harari-rural", "Harari-urban", "Harari rural", "Harari urban",
"Huye", "Huye - rural", "Huye - urban", "Kamonyi", "Kamonyi - rural",
"Kamonyi - urban", "Kampala", "Karamoja", "Karonga - rural",
"Karonga - urban", "Karongi", "Karongi - rural", "Karongi - urban",
"Kasungu - rural", "Kasungu - urban", "Kayonza", "Kayonza - rural",
"Kayonza - urban", "Kicukiro", "Kicukiro - rural", "Kicukiro - urban",
"Kigezi", "Kirehe", "Kirehe - rural", "Kirehe - urban", "Lango",
"Likoma - rural", "Likoma - urban", "Lilongwe - rural", "Lilongwe - urban",
"Lofa - Rural", "Lofa - Urban", "Lofa Rural", "Lofa Urban", "Machinga - rural",
"Machinga - urban", "Mangochi - rural", "Mangochi - urban", "Manicaland - Rural",
"Manicaland - Urban", "Margibi - Rural", "Margibi - Urban", "Margibi Rural",
"Margibi Urban", "Maryland - Rural", "Maryland - Urban", "Maryland Rural",
"Maryland Urban", "Mashonaland Central - Rural", "Mashonaland Central - Urban",
"Mashonaland East - Rural", "Mashonaland East - Urban", "Mashonaland West - Rural",
"Mashonaland West - Urban", "Masvingo - Rural", "Masvingo - Urban",
"Matabeleland North - Rural", "Matabeleland North - Urban", "Matabeleland South - Rural",
"Matabeleland South - Urban", "Mchinji - rural", "Mchinji - urban",
"Midlands - Rural", "Midlands - Urban", "Montserrado - Rural",
"Montserrado - Urban", "Montserrado Rural", "Montserrado Urban",
"Muhanga", "Muhanga - rural", "Muhanga - urban", "Mulanje - rural",
"Mulanje - urban", "Musanze", "Musanze - rural", "Musanze - urban",
"Mwanza - rural", "Mwanza - urban", "Mzimba - rural", "Mzimba - urban",
"National", "Neno - rural", "Neno - urban", "Ngoma", "Ngoma - rural",
"Ngoma - urban", "Ngororero", "Ngororero - rural", "Ngororero - urban",
"Nimba - Rural", "Nimba - Urban", "Nimba Rural", "Nimba Urban",
"Nkhatabay - rural", "Nkhatabay - urban", "Nkhota kota - rural",
"Nkhota kota - urban", "North ( excluding refugee camps )", "North Buganda",
"North Buganda Island-rural", "North Buganda Island-urban", "Northern",
"Nsanje - rural", "Nsanje - urban", "Ntcheu - rural", "Ntcheu - urban",
"Ntchisi - rural", "Ntchisi - urban", "Nyabihu", "Nyabihu - rural",
"Nyabihu - urban", "Nyagatare", "Nyagatare - rural", "Nyagatare - urban",
"Nyamagabe", "Nyamagabe - rural", "Nyamagabe - urban", "Nyamasheke",
"Nyamasheke - rural", "Nyamasheke - urban", "Nyanza", "Nyanza - rural",
"Nyanza - urban", "Nyarugenge", "Nyarugenge - rural", "Nyarugenge - urban",
"Nyaruguru", "Nyaruguru - rural", "Nyaruguru - urban", "Oromia-rural",
"Oromia-urban", "Oromiya rural", "Oromiya urban", "Phalombe - rural",
"Phalombe - urban", "Refugee camps", "River Cess - Rural", "River Cess - Urban",
"River Gee - Rural", "River Gee - Urban", "River Gee Rural",
"River Gee Urban", "Rivercess Rural", "Rivercess Urban", "Rubavu",
"Rubavu - rural", "Rubavu - urban", "Ruhango", "Ruhango - rural",
"Ruhango - urban", "Rulindo", "Rulindo - rural", "Rulindo - urban",
"Rumphi - rural", "Rumphi - urban", "Rural : Harare", "Rural : Manicaland",
"Rural : Mashonaland Central", "Rural : Mashonaland East", "Rural : Mashonaland West",
"Rural : Masvingo", "Rural : Matabeleland North", "Rural : Matabeleland South",
"Rural : Midlands", "Rusizi", "Rusizi - rural", "Rusizi - urban",
"Rutsiro", "Rutsiro - rural", "Rutsiro - urban", "Rwamagana",
"Rwamagana - rural", "Rwamagana - urban", "S.N.N.P. rural", "S.N.N.P. urban",
"Salima - rural", "Salima - urban", "Sinoe - Rural", "Sinoe - Urban",
"Sinoe Rural", "Sinoe Urban", "SNNPR-rural", "SNNPR-urban", "Somali-rural",
"Somali-urban", "Somali oversample rural", "Somali oversample urban",
"Somali rural", "Somali urban", "South Buganda", "South Buganda Island-rural",
"South Buganda Island-urban", "Southern", "Southwest", "Teso",
"Thyolo - rural", "Thyolo - urban", "Tigray-rural", "Tigray-urban",
"Tigray rural", "Tigray urban", "Tooro", "Urban : Bulawayo",
"Urban : Harare", "Urban : Manicaland", "Urban : Mashonaland Central",
"Urban : Mashonaland East", "Urban : Mashonaland West", "Urban : Masvingo",
"Urban : Matabeleland North", "Urban : Matabeleland South", "Urban : Midlands",
"West Nile", "Western", "Zomba - rural", "Zomba - urban")), class = c("haven_labelled",
"vctrs_vctr", "integer")), hv024 = structure(c(6L, 6L, 6L), labels = structure(1:66, names = c("Acholi",
"Addis Ababa", "Addis Adaba", "Afar", "Affar", "Amhara", "Ankole",
"Benishangul", "Benishangul-Gumuz", "Bugisu", "Bukedi", "Bulawayo",
"Bunyoro", "Busoga", "Central", "Central 1", "Central 2", "Central region",
"Dire Dawa", "East", "East Central", "Eastern", "Gambela", "Harare",
"Harari", "Kampala", "Karamoja", "Kigali", "Kigali City", "Kigezi",
"Lango", "Manicaland", "Mashonaland Central", "Mashonaland East",
"Mashonaland West", "Masvingo", "Matabeleland North", "Matabeleland South",
"Midlands", "Monrovia", "North", "North Buganda", "North Central",
"North Western", "Northern", "Northern region", "Oromia", "Oromiya",
"SNNP", "SNNPR", "Somali", "South", "South Buganda", "South Central",
"South Eastern A", "South Eastern B", "Southern", "Southern region",
"Southwest", "Teso", "Tigray", "Tooro", "West", "West-Nile",
"West Nile", "Western")), class = c("haven_labelled", "vctrs_vctr",
"integer")), hv025 = structure(c(2, 2, 2), labels = c(Urban = 1,
Rural = 2), label = "Type of place of residence", class = c("haven_labelled",
"vctrs_vctr", "double"))), row.names = c("ETPR61SV.1", "ETPR61SV.2",
"ETPR61SV.3"), class = "data.frame")
and
dput(comb_extract_HW_res[1:3,1:10])
structure(list(hhid = c(" 1 1", " 1 1", " 1 1"
), hvidx = c(1, 1, 2), FileName = c("MW", "RW", "MW"), hv001 = c(1,
1, 1), hv002 = c(1, 1, 1), hv005 = c(476295, 1402416, 476295),
hv006 = c(12, 4, 12), hv007 = c(2004, 2005, 2004), hv021 = c(1,
1, 1), hv023 = structure(c(29L, 20L, 29L), labels = structure(1:55, names = c("Addis Ababa - rural",
"Addis Ababa - urban", "Afar - rural", "Afar - urban", "Amhara - rural",
"Amhara - urban", "Ben-Gumz - rural", "Ben-Gumz - urban",
"Blantyre District", "Bulawayo", "Butare", "Byumba", "Cyangugu",
"Dire Dawa - rural", "Dire Dawa - urban", "Gambela - rural",
"Gambela - urban", "Gikongoro", "Gisenyi", "Gitarama", "Harare",
"Harari - rural", "Harari - urban", "Kasungu District", "Kibungo",
"Kibuye", "Kigali Ngali", "Lilongwe District", "Machinga District",
"Mangochi District", "Manicaland", "Mashonaland Central",
"Mashonaland East", "Mashonaland West", "Masvingo", "Matebeleland North",
"Matebeleland South", "Midlands", "Mulanje District", "Mzimba District",
"Oromiya - rural", "Oromiya - urban", "Rest of Malawi", "Ruhengeri",
"Salima District", "SNNP - rural", "SNNP - urban", "Somali - rural",
"Somali - urban", "Thyolo District", "Tigray - rural", "Tigray - urban",
"Umutara", "Ville de Kigali", "Zomba District")), class = c("haven_labelled",
"vctrs_vctr", "integer"))), row.names = c(NA, 3L), class = "data.frame")
I am creating an AWS State machine - I am getting an error:
Here is the site that the error links too: https://docs.aws.amazon.com/step-functions/latest/dg/concepts-amazon-states-language.html
I have been combing through my state machine code for hours, and I can't figure out what is wrong with it. Previously when I had errors, they showed up in the GUI - but for this, it just says there is an error with no indication of where the error is from.
Here is my state machine visualized:
Here is the code for my state machine:
{
"StartAt":"Pass",
"States":{
"Pass":{
"Type":"Pass",
"Next":"Transform 1"
},
"Send Notification 1":{
"Type":"Task",
"Resource":"arn:aws:states:::lambda:invoke",
"Parameters":{
"FunctionName":"arn:aws:lambda:us-east-1:432700302163:function:CheckInterviewStatus:$LATEST",
"Payload":{
"Input.$":"$"
}
},
"Catch":[
{
"ErrorEquals":[
"States.ALL"
],
"Next":"CatchAllFallback"
}
],
"Next":"Interview Completed 1"
},
"Send Notification 2":{
"Type":"Task",
"Resource":"arn:aws:states:::lambda:invoke",
"Parameters":{
"FunctionName":"arn:aws:lambda:us-east-1:432700302163:function:CheckInterviewStatus:$LATEST",
"Payload":{
"Input.$":"$.Payload"
}
},
"Catch":[
{
"ErrorEquals":[
"States.ALL"
],
"Next":"CatchAllFallback"
}
],
"Next":"Interview Completed 2"
},
"CatchAllFallback":{
"Type":"Pass",
"Result":"This is a fallback from any error code",
"End":false
},
"Send Notification 3":{
"Type":"Task",
"Resource":"arn:aws:states:::lambda:invoke",
"Parameters":{
"FunctionName":"arn:aws:lambda:us-east-1:432700302163:function:CheckInterviewStatus:$LATEST",
"Payload":{
"Input.$":"$.Payload"
}
},
"Catch":[
{
"ErrorEquals":[
"States.ALL"
],
"Next":"CatchAllFallback"
}
],
"Next":"Interview Completed 3"
},
"CatchAllFallback":{
"Type":"Pass",
"Result":"This is a fallback from any error code",
"End":false
},
"Send Notification 4":{
"Type":"Task",
"Resource":"arn:aws:states:::lambda:invoke",
"Parameters":{
"FunctionName":"arn:aws:lambda:us-east-1:432700302163:function:CheckInterviewStatus:$LATEST",
"Payload":{
"Input.$":"$.Payload"
}
},
"Catch":[
{
"ErrorEquals":[
"States.ALL"
],
"Next":"CatchAllFallback"
}
],
"Next":"Interview Completed 4"
},
"CatchAllFallback":{
"Type":"Pass",
"Result":"This is a fallback from any error code",
"End":false
},
"CatchAllFallback":{
"Type":"Pass",
"Result":"This is a fallback from any error code",
"End":false
},
"Interview Completed 1":{
"Type":"Choice",
"Choices":[
{
"Variable":"$.Payload.completed",
"BooleanEquals":true,
"Next":"Yes 1"
},
{
"Variable":"$.Payload.completed",
"BooleanEquals":false,
"Next":"No 1"
}
],
"Default":"No 1"
},
"No 1":{
"Type":"Pass",
"Next":"Wait 1"
},
"Yes 1":{
"Type":"Pass",
"End":true
},
"Interview Completed 2":{
"Type":"Choice",
"Choices":[
{
"Variable":"$.Payload.completed",
"BooleanEquals":true,
"Next":"Yes 2"
},
{
"Variable":"$.Payload.completed",
"BooleanEquals":false,
"Next":"No 2"
}
],
"Default":"No 2"
},
"No 2":{
"Type":"Pass",
"Next":"Wait 2"
},
"Yes 2":{
"Type":"Pass",
"End":true
},
"Interview Completed 3":{
"Type":"Choice",
"Choices":[
{
"Variable":"$.Payload.completed",
"BooleanEquals":true,
"Next":"Yes 3"
},
{
"Variable":"$.Payload.completed",
"BooleanEquals":false,
"Next":"No 3"
}
],
"Default":"No 3"
},
"No 3":{
"Type":"Pass",
"Next":"Wait 3"
},
"Yes 3":{
"Type":"Pass",
"End":true
},
"Interview Completed 4":{
"Type":"Choice",
"Choices":[
{
"Variable":"$.Payload.completed",
"BooleanEquals":true,
"Next":"Yes 4"
},
{
"Variable":"$.Payload.completed",
"BooleanEquals":false,
"Next":"No 4"
}
],
"Default":"No 4"
},
"No 4":{
"Type":"Pass",
"End":true
},
"Yes 4":{
"Type":"Pass",
"End":true
},
"Transform 1":{
"Type":"Pass",
"Result":0,
"Next":"Send Notification 1"
},
"Transform 2":{
"Type":"Pass",
"Result":2,
"Next":"Send Notification 2"
},
"Transform 3":{
"Type":"Pass",
"Result":2,
"Next":"Send Notification 3"
},
"Transform 4":{
"Type":"Pass",
"Result":1,
"Next":"Send Notification 4"
},
"Wait 1":{
"Type":"Wait",
"Seconds":1,
"Next":"Transform 2"
},
"Wait 2":{
"Type":"Wait",
"Seconds":1,
"Next":"Transform 3"
},
"Wait 3":{
"Type":"Wait",
"Seconds":1,
"Next":"Transform 4"
}
}
}
A pointer in the right direction would be extremely helpful.
I figured it out.
"CatchAllFallback":{
"Type":"Pass",
"Result":"This is a fallback from any error code",
"End":false
},
Was defined multiple times - which was causing the error.
Issue: While downloading through tabulator all the column formatting is removed. I am aware of using accessors to reformat the data before downloading. This way I can define formatting for individual columns. However, for column calculations, I am unable to define formatting for calculation results at the time of downloading in pdf format. In addition, I want row groups headers to have proper indentation as its available in tabulator.
Implemented code:
var tabledata = [
{
"Department": "Dept1",
"Promo Name": "$2 Off",
"Menu": "BURGER",
"Check #": "111",
"Settled By": "aaaaa",
"Discount By": "aaaaa",
"Price": "12.50",
"Discount": "2.00",
"Count of PromoID": "1"
},
{
"Department": "Dept1",
"Promo Name": "$2 Off",
"Menu": "soda",
"Check #": "1112",
"Settled By": "emp2",
"Discount By": "emp2",
"Price": "11.95",
"Discount": "2.00",
"Count of PromoID": "1"
},
{
"Department": "Dept1",
"Promo Name": "10% Off",
"Menu": "BURGER",
"Check #": "112",
"Settled By": "aaaaa",
"Discount By": "aaaaa",
"Price": "12.50",
"Discount": "0.00",
"Count of PromoID": "1"
},
{
"Department": "Dept1",
"Promo Name": "10% Off",
"Menu": "Water",
"Check #": "1122",
"Settled By": "aaaaa",
"Discount By": "aaaaa",
"Price": "1.85",
"Discount": "0.00",
"Count of PromoID": "1"
},
{
"Department": "Dept1",
"Promo Name": "222",
"Menu": "menu2",
"Check #": "1134",
"Settled By": "emp3",
"Discount By": "emp3",
"Price": "10.25",
"Discount": "2.00",
"Count of PromoID": "1"
},
{
"Department": "Dept1",
"Promo Name": "meal",
"Menu": "pizza",
"Check #": "1156",
"Settled By": "emp3",
"Discount By": "emp3",
"Price": "12.95",
"Discount": "6.48",
"Count of PromoID": "1"
},
{
"Department": "Dept1",
"Promo Name": "meal",
"Menu": "BURGER",
"Check #": "11562",
"Settled By": "aaaaa",
"Discount By": "aaaaa",
"Price": "12.50",
"Discount": "3.13",
"Count of PromoID": "1"
},
{
"Department": "Dept1",
"Promo Name": "meal",
"Menu": "sandwich",
"Check #": "157",
"Settled By": "emp2",
"Discount By": "emp2",
"Price": "56.25",
"Discount": "28.13",
"Count of PromoID": "1"
},
{
"Department": "Dept1",
"Promo Name": "meal",
"Menu": "coke",
"Check #": "27818",
"Settled By": "aaaaa",
"Discount By": "aaaaa",
"Price": "3.00",
"Discount": "1.50",
"Count of PromoID": "1"
},
{
"Department": "Dept1",
"Promo Name": "meal",
"Menu": "juice",
"Check #": "13346",
"Settled By": "aaaaa",
"Discount By": "aaaaa",
"Price": "3.00",
"Discount": "1.50",
"Count of PromoID": "1"
}
];
const formatter = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
minimumFractionDigits: 2
})
var colMoneyFormatter = function (value, data, type, params, column) {
return formatter.format(value);
}
//create Tabulator on DOM element with id "example-table"
var table = new Tabulator("#example-table",
{
//height: 205, // set height of table (in CSS or here), this enables the Virtual DOM and improves render speed dramatically (can be any valid css height value)
data: tabledata //assign data to table
,
layout: "fitData" //fit columns to width of table (optional)
,
groupClosedShowCalcs: [true, true],
columnCalcs: "both",
groupBy: ["Department", "Promo Name"],
groupStartOpen: [true, true],
groupHeader: function(value, count, data, group) {
return value + "<span style='color:#d00; margin-left:10px;'>(" + count + " item)</span>";
},
groupToggleElement: ["arrow", "arrow"],
columns: [
{ title: "Department", field: "Department", formatter: "plaintext" },
{ title: "Promo Name", field: "Promo Name", formatter: "plaintext" },
{ title: "Description", field: "Menu", formatter: "plaintext" }, {
title: "Price",
field: "Price",
accessorDownload: colMoneyFormatter,
formatter: "money",
bottomCalc: "sum",
bottomCalcParams: { precision: 2 },
bottomCalcFormatter: "money",
bottomCalcFormatterParams: {
decimal: ".",
thousand: ",",
symbol: "$"
},
formatterParams: {
decimal: ".",
thousand: ",",
symbol: "$"
}
}, {
title: "Discount",
field: "Discount",
accessorDownload: colMoneyFormatter,
formatter: "money",
bottomCalc: "sum",
bottomCalcParams: { precision: 2 },
bottomCalcFormatter: "money",
bottomCalcFormatterParams: {
decimal: ".",
thousand: ",",
symbol: "$"
},
formatterParams: {
decimal: ".",
thousand: ",",
symbol: "$"
}
}, { title: "Check #", field: "Check #", formatter: "plaintext" },
{ title: "Settled By", field: "Settled By", formatter: "plaintext" },
{ title: "Discount By", field: "Discount By", formatter: "plaintext" }
]
});
//trigger download of data.pdf file
$("#download-pdf").click(function () {
table.download("pdf",
"data.pdf",
{
orientation: "landscape" //set page orientation to portrait
,
title: "Detailed Promo Report" //add title to report
,
autoTable: {
margin: {
top: 60
}
}
});
});
I want my pdf to look exactly like tabulator table with some additional rows, headers, and footers.
Any help will be greatly appreciated.
<!DOCTYPE html>
<html lang="en">
<head>
<link href="https://unpkg.com/tabulator-tables#4.2.7/dist/css/tabulator.min.css" rel="stylesheet">
<script src="https://unpkg.com/tabulator-tables#4.2.7/dist/js/tabulator.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.5.3/jspdf.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.0.5/jspdf.plugin.autotable.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
<button id="download-pdf">Download PDF</button>
<div id="example-table"></div>
</body>
</html>
<script>
var tabledata = [{
"Department": "Dept1",
"Promo Name": "$2 Off",
"Menu": "BURGER",
"Check #": "111",
"Settled By": "aaaaa",
"Discount By": "aaaaa",
"Price": "12.50",
"Discount": "2.00",
"Count of PromoID": "1"
},
{
"Department": "Dept1",
"Promo Name": "$2 Off",
"Menu": "soda",
"Check #": "1112",
"Settled By": "emp2",
"Discount By": "emp2",
"Price": "11.95",
"Discount": "2.00",
"Count of PromoID": "1"
},
{
"Department": "Dept1",
"Promo Name": "10% Off",
"Menu": "BURGER",
"Check #": "112",
"Settled By": "aaaaa",
"Discount By": "aaaaa",
"Price": "12.50",
"Discount": "0.00",
"Count of PromoID": "1"
},
{
"Department": "Dept1",
"Promo Name": "10% Off",
"Menu": "Water",
"Check #": "1122",
"Settled By": "aaaaa",
"Discount By": "aaaaa",
"Price": "1.85",
"Discount": "0.00",
"Count of PromoID": "1"
},
{
"Department": "Dept1",
"Promo Name": "222",
"Menu": "menu2",
"Check #": "1134",
"Settled By": "emp3",
"Discount By": "emp3",
"Price": "10.25",
"Discount": "2.00",
"Count of PromoID": "1"
},
{
"Department": "Dept1",
"Promo Name": "meal",
"Menu": "pizza",
"Check #": "1156",
"Settled By": "emp3",
"Discount By": "emp3",
"Price": "12.95",
"Discount": "6.48",
"Count of PromoID": "1"
},
{
"Department": "Dept1",
"Promo Name": "meal",
"Menu": "BURGER",
"Check #": "11562",
"Settled By": "aaaaa",
"Discount By": "aaaaa",
"Price": "12.50",
"Discount": "3.13",
"Count of PromoID": "1"
},
{
"Department": "Dept1",
"Promo Name": "meal",
"Menu": "sandwich",
"Check #": "157",
"Settled By": "emp2",
"Discount By": "emp2",
"Price": "56.25",
"Discount": "28.13",
"Count of PromoID": "1"
},
{
"Department": "Dept1",
"Promo Name": "meal",
"Menu": "coke",
"Check #": "27818",
"Settled By": "aaaaa",
"Discount By": "aaaaa",
"Price": "3.00",
"Discount": "1.50",
"Count of PromoID": "1"
},
{
"Department": "Dept1",
"Promo Name": "meal",
"Menu": "juice",
"Check #": "13346",
"Settled By": "aaaaa",
"Discount By": "aaaaa",
"Price": "3.00",
"Discount": "1.50",
"Count of PromoID": "1"
}
];
const formatter = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
minimumFractionDigits: 2
})
var colMoneyFormatter = function(value, data, type, params, column) {
return formatter.format(value);
}
const table = new Tabulator("#example-table", {
data: tabledata,
layout: "fitData",
groupClosedShowCalcs: [true, true],
columnCalcs: "both",
groupBy: ["Department", "Promo Name"],
groupStartOpen: [true, true],
groupHeader: function(value, count, data, group) {
return value + "<span style='color:#d00; margin-left:10px;'>(" + count + " item)</span>";
},
groupToggleElement: ["arrow", "arrow"],
columns: [{
title: "Department",
field: "Department",
formatter: "plaintext"
},
{
title: "Promo Name",
field: "Promo Name",
formatter: "plaintext"
},
{
title: "Description",
field: "Menu",
formatter: "plaintext"
}, {
title: "Price",
field: "Price",
accessorDownload: colMoneyFormatter,
formatter: "money",
bottomCalc: "sum",
bottomCalcParams: {
precision: 2
},
bottomCalcFormatter: "money",
bottomCalcFormatterParams: {
decimal: ".",
thousand: ",",
symbol: "$"
},
formatterParams: {
decimal: ".",
thousand: ",",
symbol: "$"
}
}, {
title: "Discount",
field: "Discount",
accessorDownload: colMoneyFormatter,
formatter: "money",
bottomCalc: "sum",
bottomCalcParams: {
precision: 2
},
bottomCalcFormatter: "money",
bottomCalcFormatterParams: {
decimal: ".",
thousand: ",",
symbol: "$"
},
formatterParams: {
decimal: ".",
thousand: ",",
symbol: "$"
}
}, {
title: "Check #",
field: "Check #",
formatter: "plaintext"
},
{
title: "Settled By",
field: "Settled By",
formatter: "plaintext"
},
{
title: "Discount By",
field: "Discount By",
formatter: "plaintext"
}
]
});
//trigger download of data.pdf file
$("#download-pdf").click(function(){
table.download("pdf", "data.pdf", {
orientation:"portrait", //set page orientation to portrait
title:"Example Report" //add title to report
});
});
</script>
products = [
{"id":1, "name": "Chocolate Sandwich Cookies", "department": "snacks", "aisle": "cookies cakes", "price": 3.50},
{"id":2, "name": "All-Seasons Salt", "department": "pantry", "aisle": "spices seasonings", "price": 4.99},
{"id":3, "name": "Robust Golden Unsweetened Oolong Tea", "department": "beverages", "aisle": "tea", "price": 2.49},
{"id":4, "name": "Smart Ones Classic Favorites Mini Rigatoni With Vodka Cream Sauce", "department": "frozen", "aisle": "frozen meals", "price": 6.99},
{"id":5, "name": "Green Chile Anytime Sauce", "department": "pantry", "aisle": "marinades meat preparation", "price": 7.99},
{"id":6, "name": "Dry Nose Oil", "department": "personal care", "aisle": "cold flu allergy", "price": 21.99},
{"id":7, "name": "Pure Coconut Water With Orange", "department": "beverages", "aisle": "juice nectars", "price": 3.50},
{"id":8, "name": "Cut Russet Potatoes Steam N' Mash", "department": "frozen", "aisle": "frozen produce", "price": 4.25},
{"id":9, "name": "Light Strawberry Blueberry Yogurt", "department": "dairy eggs", "aisle": "yogurt", "price": 6.50},
{"id":10, "name": "Sparkling Orange Juice & Prickly Pear Beverage", "department": "beverages", "aisle": "water seltzer sparkling water", "price": 2.99},
{"id":11, "name": "Peach Mango Juice", "department": "beverages", "aisle": "refrigerated", "price": 1.99},
{"id":12, "name": "Chocolate Fudge Layer Cake", "department": "frozen", "aisle": "frozen dessert", "price": 18.50},
{"id":13, "name": "Saline Nasal Mist", "department": "personal care", "aisle": "cold flu allergy", "price": 16.00},
{"id":14, "name": "Fresh Scent Dishwasher Cleaner", "department": "household", "aisle": "dish detergents", "price": 4.99},
{"id":15, "name": "Overnight Diapers Size 6", "department": "babies", "aisle": "diapers wipes", "price": 25.50},
{"id":16, "name": "Mint Chocolate Flavored Syrup", "department": "snacks", "aisle": "ice cream toppings", "price": 4.50},
{"id":17, "name": "Rendered Duck Fat", "department": "meat seafood", "aisle": "poultry counter", "price": 9.99},
{"id":18, "name": "Pizza for One Suprema Frozen Pizza", "department": "frozen", "aisle": "frozen pizza", "price": 12.50},
{"id":19, "name": "Gluten Free Quinoa Three Cheese & Mushroom Blend", "department": "dry goods pasta", "aisle": "grains rice dried goods", "price": 3.99},
{"id":20, "name": "Pomegranate Cranberry & Aloe Vera Enrich Drink", "department": "beverages", "aisle": "juice nectars", "price": 4.25}
]
product_ids = []
while True:
product_id = input ("Hey please input a product identifier: ")
if product_id == "done":
break
else:
product_ids.append(product_id)
def lookup_product_by_id(product_id):
matching_products = [product for product in products if product["id"] == product_id]
return matching_products[0]
raw_total = 0
for product_id in product_ids:
product = lookup_product_by_id(product_id)
raw_total += product["price"]
print(str(product["id"]) + " " + product["name"] + " " + str(product["price"]))
It says ' list index out of range ' I don't know what is wrong with me. How can I solve this problem? I don't know how 'return matching_products[0]' and 'product = lookup_product_by_id(product_id)' are interracted.
I need to extract the following four-character matches from the below string:
Sites:
KPAE
KPSC
KPUW
KRNT
KSEA
KSFF
KSHN
KTIW
Data:
{"sids": ["24222 1", "452670 2", "PAE 3", "KPAE 5", "USW00024222 6"], "name": "EVERETT SNOHOMISH AP"},
{"sids": ["24163 1", "PSC 3", "KPSC 5", "USW00024163 6"], "name": "PASCO TRI CITIES AP"},
{"sids": ["94129 1", "PUW 3", "KPUW 5", "USW00094129 6"], "name": "PULLMAN MOSCOW RGNL AP"},
{"sids": ["94248 1", "RNT 3", "KRNT 5", "USW00094248 6"], "name": "RENTON MUNI AP"},
{"sids": ["24233 1", "457473 2", "SEA 3", "72793 4", "KSEA 5", "USW00024233 6", "SEA 7"], "name": "SEATTLE TACOMA INTL AP"},
{"sids": ["94176 1", "SFF 3", "KSFF 5", "USW00094176 6"], "name": "SPOKANE FELTS FLD"},
{"sids": ["94227 1", "457585 2", "SHN 3", "KSHN 5", "USW00094227 6", "SHN 7"], "name": "SHELTON SANDERSON FLD"},
{"sids": ["94274 1", "TIW 3", "KTIW 5", "USW00094274 6"], "name": "TACOMA NARROWS AP"},
I have tried to extract these matches from the strings but, the position of them can change from string to string...
Attempted Code:
awk -F',' '{print $5}'
Using grep -oP:
grep -Po '"\K[A-Z]{4}\b' file
KPAE
KPSC
KPUW
KRNT
KSEA
KSFF
KSHN
KTIW