In Octave I have a large "struct" called "semi_firm" with 19 "rows" (my language might be completely wrong and confusing, believe me it's more confusing for me than for you :) and dimension 1x1. (I'm thinking about this the way I imagine it looks in Excel, so why something massive has a 1x1 dimension is completely beyond me). Some cells in the structure contain a single value, some contain multiple.
I extract the following:
out = struct("pnum", semi_firm.Patent_Number, "class", semi_firm.Class, "sub", semi_firm.Subclass)
out
becomes a 1x108033 structure. This should contain three rows and 108033 columns with in each cell exactly one value. I don't understand why it's a 1x108033 structure. After some Googling I convert that structure to a cell:
c = struct2cell(out)
c
has dimension 3x1x108033
I want to export this to a .csv file. I tried all variations of this suggestion but none work because the example has two dimensions while here it has three.
All I want is to turn c
or out
into a simple .csv file with ideally three columns (pnum
, class
, sub
) and 108,033 rows with each cell containing one value. Ideally the solution would be expandable to the situation where a single cell contains multiple values. E.g. in semi_firm, there is a "row" called "inventors". There are often multiple inventors per patent.
Following the first comment, some extra information:
I think squeeze
solves part of my problem but I still get errors when exporting stuff. Here is what I did (bad workaround):
pats = c(1,1,1) % dim 1x1
classes = c(2,1,1) % dim 1x1
subs = c(3,1,1) % dim 1x1x108033
csvwrite("pats.csv",cell2mat(pats')')
csvwrite("class.csv", cell2mat(classes')')
This works. When I create subs = c(3,1,1)
it gives me a 1x1x108033 cell. Then I use subs = squeeze(subs)
and it becomes a 108033x1 cell. Then any variation I use of csvwrite("subs.csv", cell2mat(subs))
gives me errors.
The problem seems to be that subs
and out.sub
contains a seven digit number and every digit is stored as a different value. Exporting it to .csv then creates a distortion. So I need to change the format in which that is stored to be able to export it.