I want to store cells of an Excel file with 94 rows and 104 columns (it means 9776 cells!) in a byte array as follows :
I define my array as follows :
struct StateStruct {
bytes32 description;
mapping(bytes32 => bytes32) sub_state;
}
struct ObjectStruct {
StateStruct state;
address owner;
bool isObject;
bytes32 review;
}
mapping(bytes32 => ObjectStruct) objectStructs;
bytes32[] public objectList;
bytes32[9776] ExcelFields = [bytes32("cell_1"),bytes32("cell_2"),bytes32("cell_3"), ... , bytes32("9776")]; // !!! How can I do this ? and How long does it take ?
function setExcelCell(bytes32 _id, bytes32[9776] cell_values, address _owner) public returns(bool success) {
require(!isObject(_id));
uint256 counter=0;
for(counter; counter < 9776; counter++) {
objectStructs[_id].state.sub_state[ExcelFields[counter]] = cell_values[counter]; // cell_values[counter] may be "true", "false" or other value.
}
return true;
}
According to answer and comment of User "AnAllergyToAnalogy" I defined also following "alternative function" :
mapping(uint => mapping(uint => bool)) myNestedMapping;
setMyNestedMapping(bytes32 column,bytes32 row,bool[9776] value) public returns(bool success) {
uint256 counter=0;
uint256 i=0;
uint256 j=0;
for(i; i< 9776; i++)
for(j; j< 9776; j++){
myNestedMapping[i][j] = true;
}
return true;
}
You can see a screen shot of this Excel file here : Excel File Screen Shot
You also can download this file from here : http://www.filedropper.com/usecase5heatpumpomplan
And in parallel, I'm going to save the hash of this file in a byte array or by an event.
However, in general, I am not sure my strategy for designing and developing such a Smart Contract is correct and logic ? or I'm going totally wrong ?
**
Important Note : Is it possible to use IPFS for this purpose ? and can it help us ?
**
eventis OK ? or it cost as well too much ? Thanks – Questioner May 17 '18 at 16:49