- double quoted every field,
- used the same character for the decimal radix and for the field delimiter.
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
readtable struggling to interpret spreadsheet as numbers
3 ビュー (過去 30 日間)
古いコメントを表示
Hi folks,
I'm trying to use the readtable function to interpret a spreadsheet "Alberta.csv". I've tried using detectImportOpts, sadly the variables are arranged in rows and readtable seems to want to detect them as columns.
The next attempt was as follows:
seriesAL = table2dataset(rows2vars(readtable("Alberta.csv", ReadRowNames=1, MissingRule="omitrow")));
or
seriesAL = table2array(rows2vars(readtable("Alberta.csv", ReadRowNames=1, MissingRule="omitrow")));
then if I try to complete an operation:
rgdp_AL = log(0.001 .* seriesAL{:,40})
Matlab tells me I'm using too many input arguments... If I enter:
seriesAL(:,40), I'm failing to get numbers, yet seriesAL{} doesn't want to provide the full column of values!
I'm getting very confused by the way Matlab uses tables, cells, structs, etc... Can anyone help me get numbers?
6 件のコメント
Stephen23
2024 年 8 月 7 日
編集済み: Stephen23
2024 年 8 月 7 日
"readtable struggling to interpret spreadsheet as numbers"
Yes. Because whatever tool wrote that CSV file has made several major mistakes:
Ugh!!!!
Double quotes are used to indicate that fields contain text data. So that broken CSV file is saying "these are definitely not numbers, these are text and must be imported literally as text" (there are perfectly valid instances where that may be required, e.g. credit card numbers, social security numbers, telephone numbers, post codes, etc). So that is exactly what MATLAB does.
Perhaps because it uses the same character for both the decimal radix as well as the field delimiter that tool used the double quotes in an attempt to indicate the field extents ... but this actually just adds another layer of confusion on top (rather than actually handling the delimiter-conflict at its source, which is usually trivially handled with e.g. a semi-colon field delimiter when using decimal commas).
As an aside, do not use MS Excel to view CSV files. Use a reliable text-editor if you want to see what they really contain.
"I'm getting very confused by the way Matlab uses tables, cells, structs, etc."
The real cause of your confusion is a broken CSV file. If the file was written using standard CSV practices, then you would have no problems. Which is all a long introduction to my advice that the best place to fix your MATLAB code is to fix that CSV file when it is written.
Question: how is that CSV file written? It is possible that the tool is poorly set up to use the computer locale settings.
Ezra
2024 年 8 月 7 日
Thanks Stephen23! Believe it or not, I downloaded the file from the website of Statistics Canada, lol. They explain the format here. See the following from that webpage:
- English downloads are in CSV format and use commas as the separator. French downloads are also in CSV format but use semi-colons as the separator. This is by design to accommodate the decimal display standard in French, which uses a comma (,) instead of the period (.) used in English.
This file appears to mix the formats..? I'm not sure why. The download options list "with symbols", "without symbols", neither makes a difference when the .csv is opened in Notepad.
Big thanks again, your comment led me to learn a bunch about how .csv files should be worked with. I'll be opening my .csv's in Notepad in the future.
I wish I could answer regarding how the CSV is written... but I'm not sure.
Steven Lord
2024 年 8 月 7 日
I've tried using detectImportOpts, sadly the variables are arranged in rows and readtable seems to want to detect them as columns.
That is correct. In a table array in MATLAB, one of the restrictions is that each variable (each column of the array) must be the same data type. Different variables need not contain the same type of data, like this table:
load patients
T = table(LastName, Age);
head(T) % show just the first few rows
LastName Age
____________ ___
{'Smith' } 38
{'Johnson' } 43
{'Williams'} 38
{'Jones' } 40
{'Brown' } 49
{'Davis' } 46
{'Miller' } 33
{'Wilson' } 40
where all the entries in the LastName variable are cells and all the entries in the Age variable are numbers. However you can't have a variable containing a piece of text data in one row and a number in the other. MATLAB will convert one of the pieces of data into the type of the other if you try, as in:
T2 = rows2vars(T);
T2(:, 1:6) % show just the first few columns
ans = 2x6 table
OriginalVariableNames Var1 Var2 Var3 Var4 Var5
_____________________ _________ ___________ ____________ _________ _________
{'LastName'} {'Smith'} {'Johnson'} {'Williams'} {'Jones'} {'Brown'}
{'Age' } {[ 38]} {[ 43]} {[ 38]} {[ 40]} {[ 49]}
In this case, the second row of T2 has the numbers that were in the Age variable in T stored in cells because that's what the LastName variable in T contained.
Stephen23
2024 年 8 月 7 日
@Ezra: thanks for the interesting link. Which language did you download? Perhaps try downloading the other one.
"English downloads are in CSV format and use commas as the separator. French downloads are also in CSV format but use semi-colons as the separator. This is by design to accommodate the decimal display standard in French, which uses a comma (,) instead of the period (.) used in English."
Neither of those descriptions matches the format of the file that you uploaded. Very odd.
However if someone used MS Excel to open and save the file then all bets are off: Excel mangles things without warning.
Ezra
2024 年 8 月 7 日
編集済み: Ezra
2024 年 8 月 7 日
Okay, I made sure to redownload the files and open them in Notepad without any Excel interactions - same format as the older CSV's!
I've attached the french version: note, it uses semi-colons which matches the description, but not commas for decimal display standard (unless I'm mistaken). Hahaha. What gives? It's a mystery.
採用された回答
Stephen23
2024 年 8 月 7 日
編集済み: Stephen23
2024 年 8 月 7 日
"readtable struggling to interpret spreadsheet as numbers"
Unfortunately due to that broken CSV format we need to import everything as text before converting to numeric:
T = readtable('Alberta.csv', ReadRowNames=true, MissingRule="omitrow");
T = rows2vars(T, VariableNamingRule="preserve")
T = 42x41 table
OriginalVariableNames Estimates Final consumption expenditure Household final consumption expenditure Goods Durable goods Semi-durable goods Non-durable goods Services Non-profit institutions serving households' final consumption e General governments final consumption expenditure Gross fixed capital formation Business gross fixed capital formation Residential structures Non-residential structures, machinery and equipment Non-residential structures Machinery and equipment Intellectual property products Non-profit institutions serving households' gross fixed capital General governments gross fixed capital formation Investment in inventories Of which: business investment in inventories Non-farm Farm Exports of goods and services Exports to other countries Exports of goods to other countries Exports of services to other countries Exports to other provinces Exports of goods to other provinces Exports of services to other provinces Less: imports of goods and services Imports from other countries Imports of goods from other countries Imports of services from other countries Imports from other provinces Imports of goods from other provinces Imports of services from other provinces Statistical discrepancy Gross domestic product at market prices Final domestic demand
_____________________ _________ _____________________________ _______________________________________ __________ _____________ __________________ _________________ __________ _______________________________________________________________ _________________________________________________ _____________________________ ______________________________________ ______________________ ___________________________________________________ __________________________ _______________________ ______________________________ _______________________________________________________________ _________________________________________________ _________________________ ____________________________________________ __________ __________ _____________________________ __________________________ ___________________________________ ______________________________________ __________________________ ___________________________________ ______________________________________ ___________________________________ ____________________________ _____________________________________ ________________________________________ ____________________________ _____________________________________ ________________________________________ _______________________ _______________________________________ _____________________
{'Alberta'} {'1981'} {'74,785'} {'49,421'} {'23,172'} {'4,111'} {'3,068'} {'17,803'} {'25,632'} {'864' } {'25,706'} {'40,943'} {'34,948'} {'9,953'} {'22,704'} {'24,940'} {'3,539'} {'2,527'} {'127'} {'6,012'} {'186' } {'180' } {'110' } {'75' } {'47,401'} {'15,698'} {'14,281'} {'1,577'} {'32,721'} {'22,478'} {'9,397' } {'46,377'} {'14,719'} {'11,726'} {'3,154'} {'33,093'} {'17,968'} {'15,048'} {'-1,083'} {'121,088'} {'119,315'}
{'Var2' } {'1982'} {'74,931'} {'48,922'} {'22,394'} {'3,565'} {'2,935'} {'18,175'} {'26,074'} {'872' } {'26,571'} {'36,555'} {'29,290'} {'7,932'} {'19,227'} {'21,172'} {'2,983'} {'2,158'} {'130'} {'7,266'} {'-2,088'} {'-2,046'} {'-1,652'} {'-136' } {'45,593'} {'16,062'} {'14,639'} {'1,551'} {'30,082'} {'20,577'} {'8,752' } {'40,115'} {'11,879'} {'9,247' } {'2,922'} {'29,738'} {'15,679'} {'14,000'} {'-1,368'} {'118,052'} {'114,339'}
{'Var3' } {'1983'} {'76,465'} {'49,051'} {'22,379'} {'3,689'} {'2,944'} {'17,878'} {'26,236'} {'806' } {'28,429'} {'29,889'} {'23,914'} {'6,739'} {'15,588'} {'16,329'} {'2,645'} {'1,724'} {'105'} {'5,978'} {'-865' } {'-841' } {'-448' } {'-466' } {'46,705'} {'15,882'} {'14,511'} {'1,463'} {'31,552'} {'21,857'} {'8,814' } {'40,284'} {'11,709'} {'9,263' } {'2,638'} {'30,143'} {'15,763'} {'14,320'} {'465' } {'117,421'} {'108,311'}
{'Var4' } {'1984'} {'77,002'} {'49,488'} {'22,516'} {'3,892'} {'2,952'} {'17,655'} {'26,551'} {'760' } {'28,587'} {'26,476'} {'21,596'} {'5,201'} {'14,191'} {'14,776'} {'2,433'} {'1,973'} {'95' } {'4,893'} {'-870' } {'-857' } {'-163' } {'-1,000'} {'49,228'} {'17,851'} {'16,330'} {'1,608'} {'31,949'} {'21,897'} {'9,246' } {'35,613'} {'11,960'} {'9,607' } {'2,469'} {'24,612'} {'12,407'} {'12,155'} {'-82' } {'123,180'} {'105,083'}
{'Var5' } {'1985'} {'80,953'} {'52,267'} {'23,630'} {'4,451'} {'3,083'} {'17,872'} {'28,241'} {'862' } {'29,623'} {'28,530'} {'23,269'} {'5,454'} {'15,102'} {'16,153'} {'2,463'} {'2,441'} {'93' } {'5,284'} {'274' } {'273' } {'183' } {'83' } {'53,112'} {'21,069'} {'19,258'} {'1,925'} {'32,389'} {'21,735'} {'9,995' } {'38,399'} {'12,635'} {'10,281'} {'2,408'} {'26,875'} {'14,312'} {'12,504'} {'-433' } {'132,159'} {'111,238'}
{'Var6' } {'1986'} {'81,194'} {'52,806'} {'23,652'} {'4,569'} {'3,148'} {'17,551'} {'28,828'} {'866' } {'29,185'} {'25,456'} {'20,027'} {'5,508'} {'13,408'} {'14,733'} {'2,072'} {'1,109'} {'91' } {'5,425'} {'1,771' } {'1,732' } {'710' } {'1,437' } {'52,010'} {'20,873'} {'19,029'} {'1,980'} {'31,441'} {'20,644'} {'10,202'} {'40,001'} {'13,147'} {'10,445'} {'2,870'} {'28,016'} {'14,623'} {'13,330'} {'525' } {'128,432'} {'108,117'}
{'Var7' } {'1987'} {'82,988'} {'54,011'} {'23,665'} {'4,632'} {'3,164'} {'17,420'} {'30,197'} {'778' } {'29,966'} {'26,461'} {'21,491'} {'6,643'} {'13,635'} {'13,505'} {'2,550'} {'1,677'} {'94' } {'4,956'} {'-158' } {'-154' } {'-125' } {'-5' } {'55,704'} {'23,330'} {'21,487'} {'1,961'} {'32,628'} {'21,340'} {'10,664'} {'41,975'} {'13,780'} {'10,872'} {'3,118'} {'29,416'} {'14,946'} {'14,404'} {'560' } {'130,777'} {'110,982'}
{'Var8' } {'1988'} {'85,503'} {'55,856'} {'24,456'} {'4,961'} {'3,187'} {'17,846'} {'31,253'} {'805' } {'30,580'} {'30,375'} {'25,655'} {'7,630'} {'16,459'} {'15,293'} {'3,409'} {'1,966'} {'99' } {'4,674'} {'805' } {'783' } {'708' } {'-105' } {'61,004'} {'27,762'} {'25,549'} {'2,357'} {'33,420'} {'21,777'} {'10,995'} {'45,755'} {'15,425'} {'12,169'} {'3,492'} {'31,583'} {'15,892'} {'15,620'} {'1,021' } {'140,853'} {'117,607'}
{'Var9' } {'1989'} {'88,840'} {'58,133'} {'25,113'} {'5,195'} {'3,272'} {'18,142'} {'32,987'} {'962' } {'31,413'} {'29,337'} {'24,800'} {'8,468'} {'15,294'} {'14,063'} {'3,218'} {'1,970'} {'103'} {'4,482'} {'115' } {'115' } {'-65' } {'299' } {'62,188'} {'28,477'} {'26,633'} {'2,003'} {'33,887'} {'22,099'} {'11,134'} {'46,418'} {'15,753'} {'12,385'} {'3,625'} {'31,920'} {'15,806'} {'16,044'} {'1,053' } {'142,912'} {'119,885'}
{'Var10' } {'1990'} {'91,375'} {'59,723'} {'25,666'} {'5,429'} {'3,325'} {'18,366'} {'34,070'} {'1,069'} {'32,271'} {'31,077'} {'26,000'} {'8,897'} {'15,682'} {'14,589'} {'3,240'} {'2,486'} {'120'} {'5,015'} {'-139' } {'-140' } {'-363' } {'469' } {'62,612'} {'29,543'} {'27,632'} {'2,078'} {'33,235'} {'21,065'} {'11,447'} {'47,336'} {'16,462'} {'13,002'} {'3,708'} {'32,103'} {'15,408'} {'16,620'} {'494' } {'146,131'} {'124,238'}
{'Var11' } {'1991'} {'90,491'} {'59,054'} {'25,215'} {'5,272'} {'3,221'} {'18,237'} {'33,909'} {'1,129'} {'31,972'} {'28,850'} {'24,181'} {'7,612'} {'14,843'} {'13,694'} {'3,110'} {'2,451'} {'128'} {'4,590'} {'748' } {'739' } {'351' } {'517' } {'63,276'} {'31,909'} {'30,129'} {'1,991'} {'31,549'} {'19,765'} {'11,060'} {'45,986'} {'17,641'} {'13,956'} {'3,941'} {'29,346'} {'13,888'} {'15,383'} {'976' } {'146,777'} {'121,105'}
{'Var12' } {'1992'} {'91,375'} {'59,645'} {'25,286'} {'5,211'} {'3,294'} {'18,285'} {'34,489'} {'1,204'} {'32,172'} {'28,383'} {'23,834'} {'8,816'} {'14,068'} {'11,411'} {'3,580'} {'2,169'} {'151'} {'4,439'} {'-1,527'} {'-1,497'} {'-859' } {'-747' } {'68,195'} {'37,411'} {'35,208'} {'2,433'} {'31,011'} {'19,526'} {'10,795'} {'46,471'} {'18,052'} {'14,338'} {'3,959'} {'29,400'} {'13,394'} {'15,925'} {'-152' } {'147,756'} {'121,560'}
{'Var13' } {'1993'} {'92,701'} {'61,392'} {'25,977'} {'5,434'} {'3,394'} {'18,636'} {'35,563'} {'1,168'} {'31,557'} {'31,413'} {'27,044'} {'8,950'} {'16,074'} {'14,204'} {'3,627'} {'3,087'} {'167'} {'4,221'} {'863' } {'845' } {'-157' } {'1,570' } {'73,583'} {'39,899'} {'37,704'} {'2,461'} {'33,932'} {'21,832'} {'11,437'} {'48,308'} {'19,640'} {'15,642'} {'4,250'} {'29,535'} {'13,311'} {'16,147'} {'-52' } {'159,234'} {'125,842'}
{'Var14' } {'1994'} {'93,724'} {'63,784'} {'26,794'} {'5,688'} {'3,486'} {'19,110'} {'37,195'} {'1,126'} {'29,758'} {'36,162'} {'32,180'} {'8,872'} {'19,729'} {'19,137'} {'3,788'} {'4,247'} {'151'} {'3,804'} {'-277' } {'-273' } {'-306' } {'130' } {'78,712'} {'43,747'} {'41,323'} {'2,713'} {'35,193'} {'23,218'} {'11,388'} {'50,638'} {'19,934'} {'15,580'} {'4,706'} {'31,756'} {'15,477'} {'16,135'} {'1,505' } {'168,049'} {'131,475'}
{'Var15' } {'1995'} {'94,882'} {'65,202'} {'27,159'} {'5,733'} {'3,652'} {'19,197'} {'38,309'} {'1,216'} {'29,193'} {'36,027'} {'32,341'} {'7,820'} {'20,143'} {'19,100'} {'4,038'} {'4,691'} {'194'} {'3,440'} {'1,584' } {'1,551' } {'830' } {'854' } {'83,092'} {'48,227'} {'45,564'} {'2,983'} {'35,030'} {'23,043'} {'11,392'} {'52,769'} {'21,138'} {'16,667'} {'4,796'} {'32,640'} {'16,011'} {'16,472'} {'1,090' } {'173,206'} {'132,536'}
{'Var16' } {'1996'} {'96,845'} {'67,067'} {'28,005'} {'6,114'} {'3,770'} {'19,444'} {'39,320'} {'1,425'} {'28,870'} {'38,041'} {'34,239'} {'8,976'} {'21,127'} {'18,522'} {'4,830'} {'4,694'} {'185'} {'3,562'} {'-120' } {'-116' } {'-21' } {'-137' } {'90,697'} {'51,695'} {'48,572'} {'3,443'} {'39,244'} {'27,627'} {'11,185'} {'56,783'} {'24,874'} {'19,915'} {'5,250'} {'32,544'} {'15,495'} {'16,939'} {'342' } {'177,367'} {'136,502'}
format long G
M = str2double(strrep(T{:,2:end},',','.')) % convert text to numeric
M = 42x40
1.0e+00 *
1981 74.785 49.421 23.172 4.111 3.068 17.803 25.632 864 25.706 40.943 34.948 9.953 22.704 24.94 3.539 2.527 127 6.012 186 180 110 75 47.401 15.698 14.281 1.577 32.721 22.478 9.397
1982 74.931 48.922 22.394 3.565 2.935 18.175 26.074 872 26.571 36.555 29.29 7.932 19.227 21.172 2.983 2.158 130 7.266 -2.088 -2.046 -1.652 -136 45.593 16.062 14.639 1.551 30.082 20.577 8.752
1983 76.465 49.051 22.379 3.689 2.944 17.878 26.236 806 28.429 29.889 23.914 6.739 15.588 16.329 2.645 1.724 105 5.978 -865 -841 -448 -466 46.705 15.882 14.511 1.463 31.552 21.857 8.814
1984 77.002 49.488 22.516 3.892 2.952 17.655 26.551 760 28.587 26.476 21.596 5.201 14.191 14.776 2.433 1.973 95 4.893 -870 -857 -163 -1 49.228 17.851 16.33 1.608 31.949 21.897 9.246
1985 80.953 52.267 23.63 4.451 3.083 17.872 28.241 862 29.623 28.53 23.269 5.454 15.102 16.153 2.463 2.441 93 5.284 274 273 183 83 53.112 21.069 19.258 1.925 32.389 21.735 9.995
1986 81.194 52.806 23.652 4.569 3.148 17.551 28.828 866 29.185 25.456 20.027 5.508 13.408 14.733 2.072 1.109 91 5.425 1.771 1.732 710 1.437 52.01 20.873 19.029 1.98 31.441 20.644 10.202
1987 82.988 54.011 23.665 4.632 3.164 17.42 30.197 778 29.966 26.461 21.491 6.643 13.635 13.505 2.55 1.677 94 4.956 -158 -154 -125 -5 55.704 23.33 21.487 1.961 32.628 21.34 10.664
1988 85.503 55.856 24.456 4.961 3.187 17.846 31.253 805 30.58 30.375 25.655 7.63 16.459 15.293 3.409 1.966 99 4.674 805 783 708 -105 61.004 27.762 25.549 2.357 33.42 21.777 10.995
1989 88.84 58.133 25.113 5.195 3.272 18.142 32.987 962 31.413 29.337 24.8 8.468 15.294 14.063 3.218 1.97 103 4.482 115 115 -65 299 62.188 28.477 26.633 2.003 33.887 22.099 11.134
1990 91.375 59.723 25.666 5.429 3.325 18.366 34.07 1.069 32.271 31.077 26 8.897 15.682 14.589 3.24 2.486 120 5.015 -139 -140 -363 469 62.612 29.543 27.632 2.078 33.235 21.065 11.447
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
And there is all of your numeric data. (Avoid using CELL2MAT & STR2NUM for this conversion, use STR2DOUBLE)
You could optionally create a table using the numeric data (which lets you refer to the columns by their names):
T = array2table(M, VariableNames=T.Properties.VariableNames(2:end))
T = 42x40 table
Estimates Final consumption expenditure Household final consumption expenditure Goods Durable goods Semi-durable goods Non-durable goods Services Non-profit institutions serving households' final consumption e General governments final consumption expenditure Gross fixed capital formation Business gross fixed capital formation Residential structures Non-residential structures, machinery and equipment Non-residential structures Machinery and equipment Intellectual property products Non-profit institutions serving households' gross fixed capital General governments gross fixed capital formation Investment in inventories Of which: business investment in inventories Non-farm Farm Exports of goods and services Exports to other countries Exports of goods to other countries Exports of services to other countries Exports to other provinces Exports of goods to other provinces Exports of services to other provinces Less: imports of goods and services Imports from other countries Imports of goods from other countries Imports of services from other countries Imports from other provinces Imports of goods from other provinces Imports of services from other provinces Statistical discrepancy Gross domestic product at market prices Final domestic demand
_________ _____________________________ _______________________________________ ______ _____________ __________________ _________________ ________ _______________________________________________________________ _________________________________________________ _____________________________ ______________________________________ ______________________ ___________________________________________________ __________________________ _______________________ ______________________________ _______________________________________________________________ _________________________________________________ _________________________ ____________________________________________ ________ _____ _____________________________ __________________________ ___________________________________ ______________________________________ __________________________ ___________________________________ ______________________________________ ___________________________________ ____________________________ _____________________________________ ________________________________________ ____________________________ _____________________________________ ________________________________________ _______________________ _______________________________________ _____________________
1981 74.785 49.421 23.172 4.111 3.068 17.803 25.632 864 25.706 40.943 34.948 9.953 22.704 24.94 3.539 2.527 127 6.012 186 180 110 75 47.401 15.698 14.281 1.577 32.721 22.478 9.397 46.377 14.719 11.726 3.154 33.093 17.968 15.048 -1.083 121.088 119.315
1982 74.931 48.922 22.394 3.565 2.935 18.175 26.074 872 26.571 36.555 29.29 7.932 19.227 21.172 2.983 2.158 130 7.266 -2.088 -2.046 -1.652 -136 45.593 16.062 14.639 1.551 30.082 20.577 8.752 40.115 11.879 9.247 2.922 29.738 15.679 14 -1.368 118.052 114.339
1983 76.465 49.051 22.379 3.689 2.944 17.878 26.236 806 28.429 29.889 23.914 6.739 15.588 16.329 2.645 1.724 105 5.978 -865 -841 -448 -466 46.705 15.882 14.511 1.463 31.552 21.857 8.814 40.284 11.709 9.263 2.638 30.143 15.763 14.32 465 117.421 108.311
1984 77.002 49.488 22.516 3.892 2.952 17.655 26.551 760 28.587 26.476 21.596 5.201 14.191 14.776 2.433 1.973 95 4.893 -870 -857 -163 -1 49.228 17.851 16.33 1.608 31.949 21.897 9.246 35.613 11.96 9.607 2.469 24.612 12.407 12.155 -82 123.18 105.083
1985 80.953 52.267 23.63 4.451 3.083 17.872 28.241 862 29.623 28.53 23.269 5.454 15.102 16.153 2.463 2.441 93 5.284 274 273 183 83 53.112 21.069 19.258 1.925 32.389 21.735 9.995 38.399 12.635 10.281 2.408 26.875 14.312 12.504 -433 132.159 111.238
1986 81.194 52.806 23.652 4.569 3.148 17.551 28.828 866 29.185 25.456 20.027 5.508 13.408 14.733 2.072 1.109 91 5.425 1.771 1.732 710 1.437 52.01 20.873 19.029 1.98 31.441 20.644 10.202 40.001 13.147 10.445 2.87 28.016 14.623 13.33 525 128.432 108.117
1987 82.988 54.011 23.665 4.632 3.164 17.42 30.197 778 29.966 26.461 21.491 6.643 13.635 13.505 2.55 1.677 94 4.956 -158 -154 -125 -5 55.704 23.33 21.487 1.961 32.628 21.34 10.664 41.975 13.78 10.872 3.118 29.416 14.946 14.404 560 130.777 110.982
1988 85.503 55.856 24.456 4.961 3.187 17.846 31.253 805 30.58 30.375 25.655 7.63 16.459 15.293 3.409 1.966 99 4.674 805 783 708 -105 61.004 27.762 25.549 2.357 33.42 21.777 10.995 45.755 15.425 12.169 3.492 31.583 15.892 15.62 1.021 140.853 117.607
1989 88.84 58.133 25.113 5.195 3.272 18.142 32.987 962 31.413 29.337 24.8 8.468 15.294 14.063 3.218 1.97 103 4.482 115 115 -65 299 62.188 28.477 26.633 2.003 33.887 22.099 11.134 46.418 15.753 12.385 3.625 31.92 15.806 16.044 1.053 142.912 119.885
1990 91.375 59.723 25.666 5.429 3.325 18.366 34.07 1.069 32.271 31.077 26 8.897 15.682 14.589 3.24 2.486 120 5.015 -139 -140 -363 469 62.612 29.543 27.632 2.078 33.235 21.065 11.447 47.336 16.462 13.002 3.708 32.103 15.408 16.62 494 146.131 124.238
1991 90.491 59.054 25.215 5.272 3.221 18.237 33.909 1.129 31.972 28.85 24.181 7.612 14.843 13.694 3.11 2.451 128 4.59 748 739 351 517 63.276 31.909 30.129 1.991 31.549 19.765 11.06 45.986 17.641 13.956 3.941 29.346 13.888 15.383 976 146.777 121.105
1992 91.375 59.645 25.286 5.211 3.294 18.285 34.489 1.204 32.172 28.383 23.834 8.816 14.068 11.411 3.58 2.169 151 4.439 -1.527 -1.497 -859 -747 68.195 37.411 35.208 2.433 31.011 19.526 10.795 46.471 18.052 14.338 3.959 29.4 13.394 15.925 -152 147.756 121.56
1993 92.701 61.392 25.977 5.434 3.394 18.636 35.563 1.168 31.557 31.413 27.044 8.95 16.074 14.204 3.627 3.087 167 4.221 863 845 -157 1.57 73.583 39.899 37.704 2.461 33.932 21.832 11.437 48.308 19.64 15.642 4.25 29.535 13.311 16.147 -52 159.234 125.842
1994 93.724 63.784 26.794 5.688 3.486 19.11 37.195 1.126 29.758 36.162 32.18 8.872 19.729 19.137 3.788 4.247 151 3.804 -277 -273 -306 130 78.712 43.747 41.323 2.713 35.193 23.218 11.388 50.638 19.934 15.58 4.706 31.756 15.477 16.135 1.505 168.049 131.475
1995 94.882 65.202 27.159 5.733 3.652 19.197 38.309 1.216 29.193 36.027 32.341 7.82 20.143 19.1 4.038 4.691 194 3.44 1.584 1.551 830 854 83.092 48.227 45.564 2.983 35.03 23.043 11.392 52.769 21.138 16.667 4.796 32.64 16.011 16.472 1.09 173.206 132.536
1996 96.845 67.067 28.005 6.114 3.77 19.444 39.32 1.425 28.87 38.041 34.239 8.976 21.127 18.522 4.83 4.694 185 3.562 -120 -116 -21 -137 90.697 51.695 48.572 3.443 39.244 27.627 11.185 56.783 24.874 19.915 5.25 32.544 15.495 16.939 342 177.367 136.502
5 件のコメント
Ezra
2024 年 8 月 7 日
This worked great! Thank you very much. I really like that you inserted the line rebuilding the table at the end.
Stephen23
2024 年 8 月 7 日
編集済み: Stephen23
2024 年 8 月 7 日
Steven Lord raised the possibility here that those commas are perhaps intended to be thousands-separators (not mentioned in the user guide!), rather than decimal radix characters. In which case... even more urrrghghghghhhh.
It seems that the main intent of this file format is to drive everyone else up the wall (I am thankfull that none of the tools I work with have the insanity of placing thousands-separators into their numeric data exports. Ugh ugh ugh).
Still, you can use the same approach I showed in my answer, by just removing the commas entirely:
T = readtable('Alberta.csv', ReadRowNames=true, MissingRule="omitrow");
T = rows2vars(T, VariableNamingRule="preserve")
T = 42x41 table
OriginalVariableNames Estimates Final consumption expenditure Household final consumption expenditure Goods Durable goods Semi-durable goods Non-durable goods Services Non-profit institutions serving households' final consumption e General governments final consumption expenditure Gross fixed capital formation Business gross fixed capital formation Residential structures Non-residential structures, machinery and equipment Non-residential structures Machinery and equipment Intellectual property products Non-profit institutions serving households' gross fixed capital General governments gross fixed capital formation Investment in inventories Of which: business investment in inventories Non-farm Farm Exports of goods and services Exports to other countries Exports of goods to other countries Exports of services to other countries Exports to other provinces Exports of goods to other provinces Exports of services to other provinces Less: imports of goods and services Imports from other countries Imports of goods from other countries Imports of services from other countries Imports from other provinces Imports of goods from other provinces Imports of services from other provinces Statistical discrepancy Gross domestic product at market prices Final domestic demand
_____________________ _________ _____________________________ _______________________________________ __________ _____________ __________________ _________________ __________ _______________________________________________________________ _________________________________________________ _____________________________ ______________________________________ ______________________ ___________________________________________________ __________________________ _______________________ ______________________________ _______________________________________________________________ _________________________________________________ _________________________ ____________________________________________ __________ __________ _____________________________ __________________________ ___________________________________ ______________________________________ __________________________ ___________________________________ ______________________________________ ___________________________________ ____________________________ _____________________________________ ________________________________________ ____________________________ _____________________________________ ________________________________________ _______________________ _______________________________________ _____________________
{'Alberta'} {'1981'} {'74,785'} {'49,421'} {'23,172'} {'4,111'} {'3,068'} {'17,803'} {'25,632'} {'864' } {'25,706'} {'40,943'} {'34,948'} {'9,953'} {'22,704'} {'24,940'} {'3,539'} {'2,527'} {'127'} {'6,012'} {'186' } {'180' } {'110' } {'75' } {'47,401'} {'15,698'} {'14,281'} {'1,577'} {'32,721'} {'22,478'} {'9,397' } {'46,377'} {'14,719'} {'11,726'} {'3,154'} {'33,093'} {'17,968'} {'15,048'} {'-1,083'} {'121,088'} {'119,315'}
{'Var2' } {'1982'} {'74,931'} {'48,922'} {'22,394'} {'3,565'} {'2,935'} {'18,175'} {'26,074'} {'872' } {'26,571'} {'36,555'} {'29,290'} {'7,932'} {'19,227'} {'21,172'} {'2,983'} {'2,158'} {'130'} {'7,266'} {'-2,088'} {'-2,046'} {'-1,652'} {'-136' } {'45,593'} {'16,062'} {'14,639'} {'1,551'} {'30,082'} {'20,577'} {'8,752' } {'40,115'} {'11,879'} {'9,247' } {'2,922'} {'29,738'} {'15,679'} {'14,000'} {'-1,368'} {'118,052'} {'114,339'}
{'Var3' } {'1983'} {'76,465'} {'49,051'} {'22,379'} {'3,689'} {'2,944'} {'17,878'} {'26,236'} {'806' } {'28,429'} {'29,889'} {'23,914'} {'6,739'} {'15,588'} {'16,329'} {'2,645'} {'1,724'} {'105'} {'5,978'} {'-865' } {'-841' } {'-448' } {'-466' } {'46,705'} {'15,882'} {'14,511'} {'1,463'} {'31,552'} {'21,857'} {'8,814' } {'40,284'} {'11,709'} {'9,263' } {'2,638'} {'30,143'} {'15,763'} {'14,320'} {'465' } {'117,421'} {'108,311'}
{'Var4' } {'1984'} {'77,002'} {'49,488'} {'22,516'} {'3,892'} {'2,952'} {'17,655'} {'26,551'} {'760' } {'28,587'} {'26,476'} {'21,596'} {'5,201'} {'14,191'} {'14,776'} {'2,433'} {'1,973'} {'95' } {'4,893'} {'-870' } {'-857' } {'-163' } {'-1,000'} {'49,228'} {'17,851'} {'16,330'} {'1,608'} {'31,949'} {'21,897'} {'9,246' } {'35,613'} {'11,960'} {'9,607' } {'2,469'} {'24,612'} {'12,407'} {'12,155'} {'-82' } {'123,180'} {'105,083'}
{'Var5' } {'1985'} {'80,953'} {'52,267'} {'23,630'} {'4,451'} {'3,083'} {'17,872'} {'28,241'} {'862' } {'29,623'} {'28,530'} {'23,269'} {'5,454'} {'15,102'} {'16,153'} {'2,463'} {'2,441'} {'93' } {'5,284'} {'274' } {'273' } {'183' } {'83' } {'53,112'} {'21,069'} {'19,258'} {'1,925'} {'32,389'} {'21,735'} {'9,995' } {'38,399'} {'12,635'} {'10,281'} {'2,408'} {'26,875'} {'14,312'} {'12,504'} {'-433' } {'132,159'} {'111,238'}
{'Var6' } {'1986'} {'81,194'} {'52,806'} {'23,652'} {'4,569'} {'3,148'} {'17,551'} {'28,828'} {'866' } {'29,185'} {'25,456'} {'20,027'} {'5,508'} {'13,408'} {'14,733'} {'2,072'} {'1,109'} {'91' } {'5,425'} {'1,771' } {'1,732' } {'710' } {'1,437' } {'52,010'} {'20,873'} {'19,029'} {'1,980'} {'31,441'} {'20,644'} {'10,202'} {'40,001'} {'13,147'} {'10,445'} {'2,870'} {'28,016'} {'14,623'} {'13,330'} {'525' } {'128,432'} {'108,117'}
{'Var7' } {'1987'} {'82,988'} {'54,011'} {'23,665'} {'4,632'} {'3,164'} {'17,420'} {'30,197'} {'778' } {'29,966'} {'26,461'} {'21,491'} {'6,643'} {'13,635'} {'13,505'} {'2,550'} {'1,677'} {'94' } {'4,956'} {'-158' } {'-154' } {'-125' } {'-5' } {'55,704'} {'23,330'} {'21,487'} {'1,961'} {'32,628'} {'21,340'} {'10,664'} {'41,975'} {'13,780'} {'10,872'} {'3,118'} {'29,416'} {'14,946'} {'14,404'} {'560' } {'130,777'} {'110,982'}
{'Var8' } {'1988'} {'85,503'} {'55,856'} {'24,456'} {'4,961'} {'3,187'} {'17,846'} {'31,253'} {'805' } {'30,580'} {'30,375'} {'25,655'} {'7,630'} {'16,459'} {'15,293'} {'3,409'} {'1,966'} {'99' } {'4,674'} {'805' } {'783' } {'708' } {'-105' } {'61,004'} {'27,762'} {'25,549'} {'2,357'} {'33,420'} {'21,777'} {'10,995'} {'45,755'} {'15,425'} {'12,169'} {'3,492'} {'31,583'} {'15,892'} {'15,620'} {'1,021' } {'140,853'} {'117,607'}
{'Var9' } {'1989'} {'88,840'} {'58,133'} {'25,113'} {'5,195'} {'3,272'} {'18,142'} {'32,987'} {'962' } {'31,413'} {'29,337'} {'24,800'} {'8,468'} {'15,294'} {'14,063'} {'3,218'} {'1,970'} {'103'} {'4,482'} {'115' } {'115' } {'-65' } {'299' } {'62,188'} {'28,477'} {'26,633'} {'2,003'} {'33,887'} {'22,099'} {'11,134'} {'46,418'} {'15,753'} {'12,385'} {'3,625'} {'31,920'} {'15,806'} {'16,044'} {'1,053' } {'142,912'} {'119,885'}
{'Var10' } {'1990'} {'91,375'} {'59,723'} {'25,666'} {'5,429'} {'3,325'} {'18,366'} {'34,070'} {'1,069'} {'32,271'} {'31,077'} {'26,000'} {'8,897'} {'15,682'} {'14,589'} {'3,240'} {'2,486'} {'120'} {'5,015'} {'-139' } {'-140' } {'-363' } {'469' } {'62,612'} {'29,543'} {'27,632'} {'2,078'} {'33,235'} {'21,065'} {'11,447'} {'47,336'} {'16,462'} {'13,002'} {'3,708'} {'32,103'} {'15,408'} {'16,620'} {'494' } {'146,131'} {'124,238'}
{'Var11' } {'1991'} {'90,491'} {'59,054'} {'25,215'} {'5,272'} {'3,221'} {'18,237'} {'33,909'} {'1,129'} {'31,972'} {'28,850'} {'24,181'} {'7,612'} {'14,843'} {'13,694'} {'3,110'} {'2,451'} {'128'} {'4,590'} {'748' } {'739' } {'351' } {'517' } {'63,276'} {'31,909'} {'30,129'} {'1,991'} {'31,549'} {'19,765'} {'11,060'} {'45,986'} {'17,641'} {'13,956'} {'3,941'} {'29,346'} {'13,888'} {'15,383'} {'976' } {'146,777'} {'121,105'}
{'Var12' } {'1992'} {'91,375'} {'59,645'} {'25,286'} {'5,211'} {'3,294'} {'18,285'} {'34,489'} {'1,204'} {'32,172'} {'28,383'} {'23,834'} {'8,816'} {'14,068'} {'11,411'} {'3,580'} {'2,169'} {'151'} {'4,439'} {'-1,527'} {'-1,497'} {'-859' } {'-747' } {'68,195'} {'37,411'} {'35,208'} {'2,433'} {'31,011'} {'19,526'} {'10,795'} {'46,471'} {'18,052'} {'14,338'} {'3,959'} {'29,400'} {'13,394'} {'15,925'} {'-152' } {'147,756'} {'121,560'}
{'Var13' } {'1993'} {'92,701'} {'61,392'} {'25,977'} {'5,434'} {'3,394'} {'18,636'} {'35,563'} {'1,168'} {'31,557'} {'31,413'} {'27,044'} {'8,950'} {'16,074'} {'14,204'} {'3,627'} {'3,087'} {'167'} {'4,221'} {'863' } {'845' } {'-157' } {'1,570' } {'73,583'} {'39,899'} {'37,704'} {'2,461'} {'33,932'} {'21,832'} {'11,437'} {'48,308'} {'19,640'} {'15,642'} {'4,250'} {'29,535'} {'13,311'} {'16,147'} {'-52' } {'159,234'} {'125,842'}
{'Var14' } {'1994'} {'93,724'} {'63,784'} {'26,794'} {'5,688'} {'3,486'} {'19,110'} {'37,195'} {'1,126'} {'29,758'} {'36,162'} {'32,180'} {'8,872'} {'19,729'} {'19,137'} {'3,788'} {'4,247'} {'151'} {'3,804'} {'-277' } {'-273' } {'-306' } {'130' } {'78,712'} {'43,747'} {'41,323'} {'2,713'} {'35,193'} {'23,218'} {'11,388'} {'50,638'} {'19,934'} {'15,580'} {'4,706'} {'31,756'} {'15,477'} {'16,135'} {'1,505' } {'168,049'} {'131,475'}
{'Var15' } {'1995'} {'94,882'} {'65,202'} {'27,159'} {'5,733'} {'3,652'} {'19,197'} {'38,309'} {'1,216'} {'29,193'} {'36,027'} {'32,341'} {'7,820'} {'20,143'} {'19,100'} {'4,038'} {'4,691'} {'194'} {'3,440'} {'1,584' } {'1,551' } {'830' } {'854' } {'83,092'} {'48,227'} {'45,564'} {'2,983'} {'35,030'} {'23,043'} {'11,392'} {'52,769'} {'21,138'} {'16,667'} {'4,796'} {'32,640'} {'16,011'} {'16,472'} {'1,090' } {'173,206'} {'132,536'}
{'Var16' } {'1996'} {'96,845'} {'67,067'} {'28,005'} {'6,114'} {'3,770'} {'19,444'} {'39,320'} {'1,425'} {'28,870'} {'38,041'} {'34,239'} {'8,976'} {'21,127'} {'18,522'} {'4,830'} {'4,694'} {'185'} {'3,562'} {'-120' } {'-116' } {'-21' } {'-137' } {'90,697'} {'51,695'} {'48,572'} {'3,443'} {'39,244'} {'27,627'} {'11,185'} {'56,783'} {'24,874'} {'19,915'} {'5,250'} {'32,544'} {'15,495'} {'16,939'} {'342' } {'177,367'} {'136,502'}
format long G
M = str2double(strrep(T{:,2:end},',','')) % convert text to numeric
M = 42x40
1981 74785 49421 23172 4111 3068 17803 25632 864 25706 40943 34948 9953 22704 24940 3539 2527 127 6012 186 180 110 75 47401 15698 14281 1577 32721 22478 9397
1982 74931 48922 22394 3565 2935 18175 26074 872 26571 36555 29290 7932 19227 21172 2983 2158 130 7266 -2088 -2046 -1652 -136 45593 16062 14639 1551 30082 20577 8752
1983 76465 49051 22379 3689 2944 17878 26236 806 28429 29889 23914 6739 15588 16329 2645 1724 105 5978 -865 -841 -448 -466 46705 15882 14511 1463 31552 21857 8814
1984 77002 49488 22516 3892 2952 17655 26551 760 28587 26476 21596 5201 14191 14776 2433 1973 95 4893 -870 -857 -163 -1000 49228 17851 16330 1608 31949 21897 9246
1985 80953 52267 23630 4451 3083 17872 28241 862 29623 28530 23269 5454 15102 16153 2463 2441 93 5284 274 273 183 83 53112 21069 19258 1925 32389 21735 9995
1986 81194 52806 23652 4569 3148 17551 28828 866 29185 25456 20027 5508 13408 14733 2072 1109 91 5425 1771 1732 710 1437 52010 20873 19029 1980 31441 20644 10202
1987 82988 54011 23665 4632 3164 17420 30197 778 29966 26461 21491 6643 13635 13505 2550 1677 94 4956 -158 -154 -125 -5 55704 23330 21487 1961 32628 21340 10664
1988 85503 55856 24456 4961 3187 17846 31253 805 30580 30375 25655 7630 16459 15293 3409 1966 99 4674 805 783 708 -105 61004 27762 25549 2357 33420 21777 10995
1989 88840 58133 25113 5195 3272 18142 32987 962 31413 29337 24800 8468 15294 14063 3218 1970 103 4482 115 115 -65 299 62188 28477 26633 2003 33887 22099 11134
1990 91375 59723 25666 5429 3325 18366 34070 1069 32271 31077 26000 8897 15682 14589 3240 2486 120 5015 -139 -140 -363 469 62612 29543 27632 2078 33235 21065 11447
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Steven Lord
2024 年 8 月 7 日
Steven Lord raised the possibility here that those commas are perhaps intended to be thousands-separators (not mentioned in the user guide!), rather than decimal radix characters. In which case... even more urrrghghghghhhh.
Yeah. Data sometimes can be as messy as a toddler or a puppy who just learned that mud exists ;)
What led me to that conclusion was the fact that the value for 1981 in the row "Final consumption expenditure" had a comma ('74,785') while the value for the row "Non-profit institutions serving households' final consumption expenditure" didn't ('864'). I was originally going to suggest, since Import Tool imported that first entry as 74785 (which I checked by hovering over its entry prior to importing) that the poster simply divide the values by 1000 but that wouldn't have made sense for 864 which didn't have a comma.
I'm wondering if whoever created this data set didn't expect anyone to try to import it into another software package than Microsoft Excel, and it was mostly going to be used to display the data rather than trying to compute with it. Thousands separators can be nice for human eyes and brains to use in reading the data, but can be painful for software to handle if there's potential ambiguity.
Ezra
2024 年 8 月 7 日
編集済み: Ezra
2024 年 8 月 7 日
That was indeed the case Stephen23! I didn't think the data and it's odd format would lead to so many comments. I had modified the
% convert text to numeric
step already, but thank you very much for your comments and engagement with the problem!
Steven Lord, that may be the case. See here. Statistics Canada focuses on annual changes from year to year, highlighting percentage growth in various economic components. Simple enough to calculate in Excel... On the other hand, the data is also quite useful for Real Business Cycle research (that's where Matlab comes in handy). Thanks again!
Steven Lord
2024 年 8 月 7 日
You asked an interesting question and showed what you'd tried. That tends to pique the interest of people on Answers.
その他の回答 (2 件)
VBBV
2024 年 8 月 6 日
編集済み: VBBV
2024 年 8 月 7 日
seriesAL = rows2vars(readtable('Alberta.csv', ReadRowNames=1, MissingRule="omitrow",VariableNamingRule='preserve'))
Warning: Table variable names that were not valid MATLAB identifiers have been modified. Since table variable names must be unique, any table variable names that happened to match the new identifiers also have been modified.
To use the original row names as new variable names, set 'VariableNamingRule' to 'preserve'.
To use the original row names as new variable names, set 'VariableNamingRule' to 'preserve'.
seriesAL = 42x41 table
OriginalVariableNames Estimates FinalConsumptionExpenditure HouseholdFinalConsumptionExpenditure Goods DurableGoods Semi_durableGoods Non_durableGoods Services Non_profitInstitutionsServingHouseholds_FinalConsumptionExpendi GeneralGovernmentsFinalConsumptionExpenditure GrossFixedCapitalFormation BusinessGrossFixedCapitalFormation ResidentialStructures Non_residentialStructures_MachineryAndEquipment Non_residentialStructures MachineryAndEquipment IntellectualPropertyProducts Non_profitInstitutionsServingHouseholds_GrossFixedCapitalFormat GeneralGovernmentsGrossFixedCapitalFormation InvestmentInInventories OfWhich_BusinessInvestmentInInventories Non_farm Farm ExportsOfGoodsAndServices ExportsToOtherCountries ExportsOfGoodsToOtherCountries ExportsOfServicesToOtherCountries ExportsToOtherProvinces ExportsOfGoodsToOtherProvinces ExportsOfServicesToOtherProvinces Less_ImportsOfGoodsAndServices ImportsFromOtherCountries ImportsOfGoodsFromOtherCountries ImportsOfServicesFromOtherCountries ImportsFromOtherProvinces ImportsOfGoodsFromOtherProvinces ImportsOfServicesFromOtherProvinces StatisticalDiscrepancy GrossDomesticProductAtMarketPrices FinalDomesticDemand
_____________________ _________ ___________________________ ____________________________________ __________ ____________ _________________ ________________ __________ _______________________________________________________________ _____________________________________________ __________________________ __________________________________ _____________________ _______________________________________________ _________________________ _____________________ ____________________________ _______________________________________________________________ ____________________________________________ _______________________ _______________________________________ __________ __________ _________________________ _______________________ ______________________________ _________________________________ _______________________ ______________________________ _________________________________ ______________________________ _________________________ ________________________________ ___________________________________ _________________________ ________________________________ ___________________________________ ______________________ __________________________________ ___________________
{'Alberta'} {'1981'} {'74,785'} {'49,421'} {'23,172'} {'4,111'} {'3,068'} {'17,803'} {'25,632'} {'864' } {'25,706'} {'40,943'} {'34,948'} {'9,953'} {'22,704'} {'24,940'} {'3,539'} {'2,527'} {'127'} {'6,012'} {'186' } {'180' } {'110' } {'75' } {'47,401'} {'15,698'} {'14,281'} {'1,577'} {'32,721'} {'22,478'} {'9,397' } {'46,377'} {'14,719'} {'11,726'} {'3,154'} {'33,093'} {'17,968'} {'15,048'} {'-1,083'} {'121,088'} {'119,315'}
{'Var2' } {'1982'} {'74,931'} {'48,922'} {'22,394'} {'3,565'} {'2,935'} {'18,175'} {'26,074'} {'872' } {'26,571'} {'36,555'} {'29,290'} {'7,932'} {'19,227'} {'21,172'} {'2,983'} {'2,158'} {'130'} {'7,266'} {'-2,088'} {'-2,046'} {'-1,652'} {'-136' } {'45,593'} {'16,062'} {'14,639'} {'1,551'} {'30,082'} {'20,577'} {'8,752' } {'40,115'} {'11,879'} {'9,247' } {'2,922'} {'29,738'} {'15,679'} {'14,000'} {'-1,368'} {'118,052'} {'114,339'}
{'Var3' } {'1983'} {'76,465'} {'49,051'} {'22,379'} {'3,689'} {'2,944'} {'17,878'} {'26,236'} {'806' } {'28,429'} {'29,889'} {'23,914'} {'6,739'} {'15,588'} {'16,329'} {'2,645'} {'1,724'} {'105'} {'5,978'} {'-865' } {'-841' } {'-448' } {'-466' } {'46,705'} {'15,882'} {'14,511'} {'1,463'} {'31,552'} {'21,857'} {'8,814' } {'40,284'} {'11,709'} {'9,263' } {'2,638'} {'30,143'} {'15,763'} {'14,320'} {'465' } {'117,421'} {'108,311'}
{'Var4' } {'1984'} {'77,002'} {'49,488'} {'22,516'} {'3,892'} {'2,952'} {'17,655'} {'26,551'} {'760' } {'28,587'} {'26,476'} {'21,596'} {'5,201'} {'14,191'} {'14,776'} {'2,433'} {'1,973'} {'95' } {'4,893'} {'-870' } {'-857' } {'-163' } {'-1,000'} {'49,228'} {'17,851'} {'16,330'} {'1,608'} {'31,949'} {'21,897'} {'9,246' } {'35,613'} {'11,960'} {'9,607' } {'2,469'} {'24,612'} {'12,407'} {'12,155'} {'-82' } {'123,180'} {'105,083'}
{'Var5' } {'1985'} {'80,953'} {'52,267'} {'23,630'} {'4,451'} {'3,083'} {'17,872'} {'28,241'} {'862' } {'29,623'} {'28,530'} {'23,269'} {'5,454'} {'15,102'} {'16,153'} {'2,463'} {'2,441'} {'93' } {'5,284'} {'274' } {'273' } {'183' } {'83' } {'53,112'} {'21,069'} {'19,258'} {'1,925'} {'32,389'} {'21,735'} {'9,995' } {'38,399'} {'12,635'} {'10,281'} {'2,408'} {'26,875'} {'14,312'} {'12,504'} {'-433' } {'132,159'} {'111,238'}
{'Var6' } {'1986'} {'81,194'} {'52,806'} {'23,652'} {'4,569'} {'3,148'} {'17,551'} {'28,828'} {'866' } {'29,185'} {'25,456'} {'20,027'} {'5,508'} {'13,408'} {'14,733'} {'2,072'} {'1,109'} {'91' } {'5,425'} {'1,771' } {'1,732' } {'710' } {'1,437' } {'52,010'} {'20,873'} {'19,029'} {'1,980'} {'31,441'} {'20,644'} {'10,202'} {'40,001'} {'13,147'} {'10,445'} {'2,870'} {'28,016'} {'14,623'} {'13,330'} {'525' } {'128,432'} {'108,117'}
{'Var7' } {'1987'} {'82,988'} {'54,011'} {'23,665'} {'4,632'} {'3,164'} {'17,420'} {'30,197'} {'778' } {'29,966'} {'26,461'} {'21,491'} {'6,643'} {'13,635'} {'13,505'} {'2,550'} {'1,677'} {'94' } {'4,956'} {'-158' } {'-154' } {'-125' } {'-5' } {'55,704'} {'23,330'} {'21,487'} {'1,961'} {'32,628'} {'21,340'} {'10,664'} {'41,975'} {'13,780'} {'10,872'} {'3,118'} {'29,416'} {'14,946'} {'14,404'} {'560' } {'130,777'} {'110,982'}
{'Var8' } {'1988'} {'85,503'} {'55,856'} {'24,456'} {'4,961'} {'3,187'} {'17,846'} {'31,253'} {'805' } {'30,580'} {'30,375'} {'25,655'} {'7,630'} {'16,459'} {'15,293'} {'3,409'} {'1,966'} {'99' } {'4,674'} {'805' } {'783' } {'708' } {'-105' } {'61,004'} {'27,762'} {'25,549'} {'2,357'} {'33,420'} {'21,777'} {'10,995'} {'45,755'} {'15,425'} {'12,169'} {'3,492'} {'31,583'} {'15,892'} {'15,620'} {'1,021' } {'140,853'} {'117,607'}
{'Var9' } {'1989'} {'88,840'} {'58,133'} {'25,113'} {'5,195'} {'3,272'} {'18,142'} {'32,987'} {'962' } {'31,413'} {'29,337'} {'24,800'} {'8,468'} {'15,294'} {'14,063'} {'3,218'} {'1,970'} {'103'} {'4,482'} {'115' } {'115' } {'-65' } {'299' } {'62,188'} {'28,477'} {'26,633'} {'2,003'} {'33,887'} {'22,099'} {'11,134'} {'46,418'} {'15,753'} {'12,385'} {'3,625'} {'31,920'} {'15,806'} {'16,044'} {'1,053' } {'142,912'} {'119,885'}
{'Var10' } {'1990'} {'91,375'} {'59,723'} {'25,666'} {'5,429'} {'3,325'} {'18,366'} {'34,070'} {'1,069'} {'32,271'} {'31,077'} {'26,000'} {'8,897'} {'15,682'} {'14,589'} {'3,240'} {'2,486'} {'120'} {'5,015'} {'-139' } {'-140' } {'-363' } {'469' } {'62,612'} {'29,543'} {'27,632'} {'2,078'} {'33,235'} {'21,065'} {'11,447'} {'47,336'} {'16,462'} {'13,002'} {'3,708'} {'32,103'} {'15,408'} {'16,620'} {'494' } {'146,131'} {'124,238'}
{'Var11' } {'1991'} {'90,491'} {'59,054'} {'25,215'} {'5,272'} {'3,221'} {'18,237'} {'33,909'} {'1,129'} {'31,972'} {'28,850'} {'24,181'} {'7,612'} {'14,843'} {'13,694'} {'3,110'} {'2,451'} {'128'} {'4,590'} {'748' } {'739' } {'351' } {'517' } {'63,276'} {'31,909'} {'30,129'} {'1,991'} {'31,549'} {'19,765'} {'11,060'} {'45,986'} {'17,641'} {'13,956'} {'3,941'} {'29,346'} {'13,888'} {'15,383'} {'976' } {'146,777'} {'121,105'}
{'Var12' } {'1992'} {'91,375'} {'59,645'} {'25,286'} {'5,211'} {'3,294'} {'18,285'} {'34,489'} {'1,204'} {'32,172'} {'28,383'} {'23,834'} {'8,816'} {'14,068'} {'11,411'} {'3,580'} {'2,169'} {'151'} {'4,439'} {'-1,527'} {'-1,497'} {'-859' } {'-747' } {'68,195'} {'37,411'} {'35,208'} {'2,433'} {'31,011'} {'19,526'} {'10,795'} {'46,471'} {'18,052'} {'14,338'} {'3,959'} {'29,400'} {'13,394'} {'15,925'} {'-152' } {'147,756'} {'121,560'}
{'Var13' } {'1993'} {'92,701'} {'61,392'} {'25,977'} {'5,434'} {'3,394'} {'18,636'} {'35,563'} {'1,168'} {'31,557'} {'31,413'} {'27,044'} {'8,950'} {'16,074'} {'14,204'} {'3,627'} {'3,087'} {'167'} {'4,221'} {'863' } {'845' } {'-157' } {'1,570' } {'73,583'} {'39,899'} {'37,704'} {'2,461'} {'33,932'} {'21,832'} {'11,437'} {'48,308'} {'19,640'} {'15,642'} {'4,250'} {'29,535'} {'13,311'} {'16,147'} {'-52' } {'159,234'} {'125,842'}
{'Var14' } {'1994'} {'93,724'} {'63,784'} {'26,794'} {'5,688'} {'3,486'} {'19,110'} {'37,195'} {'1,126'} {'29,758'} {'36,162'} {'32,180'} {'8,872'} {'19,729'} {'19,137'} {'3,788'} {'4,247'} {'151'} {'3,804'} {'-277' } {'-273' } {'-306' } {'130' } {'78,712'} {'43,747'} {'41,323'} {'2,713'} {'35,193'} {'23,218'} {'11,388'} {'50,638'} {'19,934'} {'15,580'} {'4,706'} {'31,756'} {'15,477'} {'16,135'} {'1,505' } {'168,049'} {'131,475'}
{'Var15' } {'1995'} {'94,882'} {'65,202'} {'27,159'} {'5,733'} {'3,652'} {'19,197'} {'38,309'} {'1,216'} {'29,193'} {'36,027'} {'32,341'} {'7,820'} {'20,143'} {'19,100'} {'4,038'} {'4,691'} {'194'} {'3,440'} {'1,584' } {'1,551' } {'830' } {'854' } {'83,092'} {'48,227'} {'45,564'} {'2,983'} {'35,030'} {'23,043'} {'11,392'} {'52,769'} {'21,138'} {'16,667'} {'4,796'} {'32,640'} {'16,011'} {'16,472'} {'1,090' } {'173,206'} {'132,536'}
{'Var16' } {'1996'} {'96,845'} {'67,067'} {'28,005'} {'6,114'} {'3,770'} {'19,444'} {'39,320'} {'1,425'} {'28,870'} {'38,041'} {'34,239'} {'8,976'} {'21,127'} {'18,522'} {'4,830'} {'4,694'} {'185'} {'3,562'} {'-120' } {'-116' } {'-21' } {'-137' } {'90,697'} {'51,695'} {'48,572'} {'3,443'} {'39,244'} {'27,627'} {'11,185'} {'56,783'} {'24,874'} {'19,915'} {'5,250'} {'32,544'} {'15,495'} {'16,939'} {'342' } {'177,367'} {'136,502'}
yy = strrep(seriesAL{:,40},',','')
yy = 42x1 cell array
{'121088'}
{'118052'}
{'117421'}
{'123180'}
{'132159'}
{'128432'}
{'130777'}
{'140853'}
{'142912'}
{'146131'}
{'146777'}
{'147756'}
{'159234'}
{'168049'}
{'173206'}
{'177367'}
{'189477'}
{'198807'}
{'201271'}
{'213656'}
{'217167'}
{'222143'}
{'229834'}
{'242622'}
{'253330'}
{'269426'}
{'274159'}
{'278580'}
{'263141'}
{'276213'}
rgdp_AL = log(0.001.*str2num(cell2mat(yy)))
rgdp_AL = 42x1
4.7965
4.7711
4.7658
4.8136
4.8840
4.8554
4.8735
4.9477
4.9622
4.9845
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Siddharth Bhutiya
2024 年 8 月 7 日
Others have already given good answers. I'll give another version that tweaks a few more options in readtable to simplify the conversion process. If you import the values as strings then you can use convertvars to convert these into doubles.
format long
filename = "https://www.mathworks.com/matlabcentral/answers/uploaded_files/1748189/Alberta.csv";
t = readtable(filename,ReadVariableNames=true,ReadRowNames=true,NumHeaderLines=10,MissingRule="omitrow",VariableNamingRule="preserve",TextType="string")
t = 39x42 table
1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022
________ ________ ________ ________ ________ ________ ________ ________ ________ ________ ________ ________ ________ ________ ________ ________ _________ _________ _________ _________ _________ _________ _________ _________ _________ _________ _________ _________ _________ _________ _________ _________ _________ _________ _________ _________ _________ _________ _________ _________ _________ _________
Final consumption expenditure "74,785" "74,931" "76,465" "77,002" "80,953" "81,194" "82,988" "85,503" "88,840" "91,375" "90,491" "91,375" "92,701" "93,724" "94,882" "96,845" "102,525" "106,850" "110,566" "116,613" "121,259" "126,360" "130,450" "136,210" "145,163" "155,904" "165,769" "171,723" "171,464" "177,672" "184,778" "191,218" "198,423" "204,685" "206,646" "208,493" "214,522" "219,333" "219,670" "208,764" "216,594" "223,413"
Household final consumption expenditure "49,421" "48,922" "49,051" "49,488" "52,267" "52,806" "54,011" "55,856" "58,133" "59,723" "59,054" "59,645" "61,392" "63,784" "65,202" "67,067" "72,035" "74,705" "77,277" "81,323" "84,425" "88,079" "91,003" "95,971" "103,450" "112,769" "120,296" "123,446" "121,880" "126,927" "132,063" "137,565" "144,369" "149,804" "150,554" "150,024" "154,356" "157,123" "157,750" "147,478" "154,378" "159,602"
Goods "23,172" "22,394" "22,379" "22,516" "23,630" "23,652" "23,665" "24,456" "25,113" "25,666" "25,215" "25,286" "25,977" "26,794" "27,159" "28,005" "30,234" "31,692" "32,668" "34,768" "36,338" "38,231" "39,295" "41,546" "44,815" "49,489" "52,950" "53,989" "51,993" "53,828" "56,166" "59,123" "62,393" "65,178" "63,849" "62,571" "65,159" "65,947" "65,488" "63,444" "66,309" "65,696"
Durable goods "4,111" "3,565" "3,689" "3,892" "4,451" "4,569" "4,632" "4,961" "5,195" "5,429" "5,272" "5,211" "5,434" "5,688" "5,733" "6,114" "7,180" "7,477" "7,744" "8,619" "9,318" "10,103" "10,503" "11,229" "12,850" "14,996" "16,530" "16,676" "14,781" "15,505" "16,517" "17,869" "19,408" "20,599" "19,228" "18,318" "19,734" "19,784" "19,180" "17,732" "19,213" "18,708"
Semi-durable goods "3,068" "2,935" "2,944" "2,952" "3,083" "3,148" "3,164" "3,187" "3,272" "3,325" "3,221" "3,294" "3,394" "3,486" "3,652" "3,770" "3,987" "4,261" "4,366" "4,677" "5,060" "5,357" "5,616" "6,015" "6,634" "7,481" "8,221" "8,574" "8,305" "8,795" "9,455" "10,233" "10,685" "11,072" "10,951" "10,768" "10,928" "11,080" "11,166" "9,904" "11,547" "11,872"
Non-durable goods "17,803" "18,175" "17,878" "17,655" "17,872" "17,551" "17,420" "17,846" "18,142" "18,366" "18,237" "18,285" "18,636" "19,110" "19,197" "19,444" "20,186" "21,091" "21,730" "22,495" "22,773" "23,481" "23,807" "24,897" "25,711" "27,190" "28,239" "28,758" "28,983" "29,565" "30,201" "31,023" "32,316" "33,535" "33,670" "33,486" "34,497" "35,081" "35,131" "35,752" "35,583" "35,187"
Services "25,632" "26,074" "26,236" "26,551" "28,241" "28,828" "30,197" "31,253" "32,987" "34,070" "33,909" "34,489" "35,563" "37,195" "38,309" "39,320" "42,042" "43,190" "44,815" "46,694" "48,182" "49,884" "51,787" "54,487" "58,695" "63,231" "67,271" "69,417" "69,936" "73,167" "75,959" "78,474" "81,999" "84,644" "86,716" "87,449" "89,197" "91,179" "92,270" "84,018" "88,056" "94,137"
Non-profit institutions serving households' final consumption expenditure "864" "872" "806" "760" "862" "866" "778" "805" "962" "1,069" "1,129" "1,204" "1,168" "1,126" "1,216" "1,425" "1,736" "1,890" "2,023" "2,191" "2,367" "2,642" "2,470" "2,351" "2,605" "2,552" "2,618" "2,790" "2,694" "2,656" "2,826" "2,952" "3,029" "2,991" "3,136" "3,301" "3,310" "3,429" "3,624" "3,439" "3,454" "3,525"
General governments final consumption expenditure "25,706" "26,571" "28,429" "28,587" "29,623" "29,185" "29,966" "30,580" "31,413" "32,271" "31,972" "32,172" "31,557" "29,758" "29,193" "28,870" "28,967" "30,590" "31,621" "33,528" "34,954" "36,140" "37,456" "38,198" "39,248" "40,496" "42,711" "45,477" "46,995" "48,160" "49,960" "50,748" "51,038" "51,887" "52,958" "55,168" "56,856" "58,785" "58,298" "57,810" "58,745" "60,271"
Gross fixed capital formation "40,943" "36,555" "29,889" "26,476" "28,530" "25,456" "26,461" "30,375" "29,337" "31,077" "28,850" "28,383" "31,413" "36,162" "36,027" "38,041" "48,248" "53,435" "50,899" "59,401" "66,071" "65,452" "69,925" "77,011" "93,836" "103,336" "105,515" "107,221" "79,625" "98,129" "108,826" "121,061" "134,491" "140,637" "112,731" "91,260" "91,903" "90,904" "84,688" "72,365" "80,514" "86,779"
Business gross fixed capital formation "34,948" "29,290" "23,914" "21,596" "23,269" "20,027" "21,491" "25,655" "24,800" "26,000" "24,181" "23,834" "27,044" "32,180" "32,341" "34,239" "44,411" "49,240" "46,194" "53,984" "59,343" "58,377" "63,472" "70,228" "85,696" "93,762" "94,533" "95,024" "67,399" "84,297" "95,374" "107,500" "121,740" "128,767" "99,886" "78,189" "78,881" "79,298" "74,150" "61,668" "71,144" "76,833"
Residential structures "9,953" "7,932" "6,739" "5,201" "5,454" "5,508" "6,643" "7,630" "8,468" "8,897" "7,612" "8,816" "8,950" "8,872" "7,820" "8,976" "11,379" "12,068" "11,564" "11,840" "13,186" "15,549" "14,955" "15,643" "17,676" "18,406" "18,535" "16,499" "14,356" "17,058" "16,308" "18,383" "20,351" "22,181" "22,084" "18,785" "19,185" "18,836" "17,038" "16,380" "19,993" "19,724"
Non-residential structures, machinery and equipment "22,704" "19,227" "15,588" "14,191" "15,102" "13,408" "13,635" "16,459" "15,294" "15,682" "14,843" "14,068" "16,074" "19,729" "20,143" "21,127" "27,380" "29,647" "28,605" "33,876" "36,949" "36,012" "40,957" "46,199" "57,192" "64,421" "66,670" "70,527" "47,021" "59,671" "70,425" "79,434" "91,807" "97,002" "71,172" "54,174" "53,664" "54,080" "50,802" "39,510" "45,240" "50,654"
Non-residential structures "24,940" "21,172" "16,329" "14,776" "16,153" "14,733" "13,505" "15,293" "14,063" "14,589" "13,694" "11,411" "14,204" "19,137" "19,100" "18,522" "24,349" "22,549" "22,080" "26,175" "28,194" "26,338" "28,976" "32,717" "39,864" "43,058" "45,120" "49,320" "29,602" "42,016" "50,345" "57,175" "67,703" "71,898" "52,538" "40,224" "39,707" "38,178" "35,254" "26,779" "32,906" "36,380"
Machinery and equipment "3,539" "2,983" "2,645" "2,433" "2,463" "2,072" "2,550" "3,409" "3,218" "3,240" "3,110" "3,580" "3,627" "3,788" "4,038" "4,830" "6,119" "8,231" "7,798" "9,223" "10,226" "10,500" "12,432" "14,005" "17,736" "21,284" "21,577" "21,428" "17,175" "17,755" "20,201" "22,378" "24,121" "25,091" "18,636" "13,950" "13,957" "15,902" "15,543" "12,710" "12,318" "14,275"
Intellectual property products "2,527" "2,158" "1,724" "1,973" "2,441" "1,109" "1,677" "1,966" "1,970" "2,486" "2,451" "2,169" "3,087" "4,247" "4,691" "4,694" "6,312" "8,273" "6,633" "8,549" "9,596" "7,724" "8,047" "8,745" "11,053" "11,030" "9,365" "8,286" "6,062" "7,640" "8,779" "9,836" "9,701" "9,668" "6,615" "5,224" "6,032" "6,383" "6,304" "5,837" "5,958" "6,661"
t = convertvars(t,":","double") % convert the strings to numbers
t = 39x42 table
1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022
_____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ _____ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______ ______
Final consumption expenditure 74785 74931 76465 77002 80953 81194 82988 85503 88840 91375 90491 91375 92701 93724 94882 96845 102525 106850 110566 116613 121259 126360 130450 136210 145163 155904 165769 171723 171464 177672 184778 191218 198423 204685 206646 208493 214522 219333 219670 208764 216594 223413
Household final consumption expenditure 49421 48922 49051 49488 52267 52806 54011 55856 58133 59723 59054 59645 61392 63784 65202 67067 72035 74705 77277 81323 84425 88079 91003 95971 103450 112769 120296 123446 121880 126927 132063 137565 144369 149804 150554 150024 154356 157123 157750 147478 154378 159602
Goods 23172 22394 22379 22516 23630 23652 23665 24456 25113 25666 25215 25286 25977 26794 27159 28005 30234 31692 32668 34768 36338 38231 39295 41546 44815 49489 52950 53989 51993 53828 56166 59123 62393 65178 63849 62571 65159 65947 65488 63444 66309 65696
Durable goods 4111 3565 3689 3892 4451 4569 4632 4961 5195 5429 5272 5211 5434 5688 5733 6114 7180 7477 7744 8619 9318 10103 10503 11229 12850 14996 16530 16676 14781 15505 16517 17869 19408 20599 19228 18318 19734 19784 19180 17732 19213 18708
Semi-durable goods 3068 2935 2944 2952 3083 3148 3164 3187 3272 3325 3221 3294 3394 3486 3652 3770 3987 4261 4366 4677 5060 5357 5616 6015 6634 7481 8221 8574 8305 8795 9455 10233 10685 11072 10951 10768 10928 11080 11166 9904 11547 11872
Non-durable goods 17803 18175 17878 17655 17872 17551 17420 17846 18142 18366 18237 18285 18636 19110 19197 19444 20186 21091 21730 22495 22773 23481 23807 24897 25711 27190 28239 28758 28983 29565 30201 31023 32316 33535 33670 33486 34497 35081 35131 35752 35583 35187
Services 25632 26074 26236 26551 28241 28828 30197 31253 32987 34070 33909 34489 35563 37195 38309 39320 42042 43190 44815 46694 48182 49884 51787 54487 58695 63231 67271 69417 69936 73167 75959 78474 81999 84644 86716 87449 89197 91179 92270 84018 88056 94137
Non-profit institutions serving households' final consumption expenditure 864 872 806 760 862 866 778 805 962 1069 1129 1204 1168 1126 1216 1425 1736 1890 2023 2191 2367 2642 2470 2351 2605 2552 2618 2790 2694 2656 2826 2952 3029 2991 3136 3301 3310 3429 3624 3439 3454 3525
General governments final consumption expenditure 25706 26571 28429 28587 29623 29185 29966 30580 31413 32271 31972 32172 31557 29758 29193 28870 28967 30590 31621 33528 34954 36140 37456 38198 39248 40496 42711 45477 46995 48160 49960 50748 51038 51887 52958 55168 56856 58785 58298 57810 58745 60271
Gross fixed capital formation 40943 36555 29889 26476 28530 25456 26461 30375 29337 31077 28850 28383 31413 36162 36027 38041 48248 53435 50899 59401 66071 65452 69925 77011 93836 103336 105515 107221 79625 98129 108826 121061 134491 140637 112731 91260 91903 90904 84688 72365 80514 86779
Business gross fixed capital formation 34948 29290 23914 21596 23269 20027 21491 25655 24800 26000 24181 23834 27044 32180 32341 34239 44411 49240 46194 53984 59343 58377 63472 70228 85696 93762 94533 95024 67399 84297 95374 107500 121740 128767 99886 78189 78881 79298 74150 61668 71144 76833
Residential structures 9953 7932 6739 5201 5454 5508 6643 7630 8468 8897 7612 8816 8950 8872 7820 8976 11379 12068 11564 11840 13186 15549 14955 15643 17676 18406 18535 16499 14356 17058 16308 18383 20351 22181 22084 18785 19185 18836 17038 16380 19993 19724
Non-residential structures, machinery and equipment 22704 19227 15588 14191 15102 13408 13635 16459 15294 15682 14843 14068 16074 19729 20143 21127 27380 29647 28605 33876 36949 36012 40957 46199 57192 64421 66670 70527 47021 59671 70425 79434 91807 97002 71172 54174 53664 54080 50802 39510 45240 50654
Non-residential structures 24940 21172 16329 14776 16153 14733 13505 15293 14063 14589 13694 11411 14204 19137 19100 18522 24349 22549 22080 26175 28194 26338 28976 32717 39864 43058 45120 49320 29602 42016 50345 57175 67703 71898 52538 40224 39707 38178 35254 26779 32906 36380
Machinery and equipment 3539 2983 2645 2433 2463 2072 2550 3409 3218 3240 3110 3580 3627 3788 4038 4830 6119 8231 7798 9223 10226 10500 12432 14005 17736 21284 21577 21428 17175 17755 20201 22378 24121 25091 18636 13950 13957 15902 15543 12710 12318 14275
Intellectual property products 2527 2158 1724 1973 2441 1109 1677 1966 1970 2486 2451 2169 3087 4247 4691 4694 6312 8273 6633 8549 9596 7724 8047 8745 11053 11030 9365 8286 6062 7640 8779 9836 9701 9668 6615 5224 6032 6383 6304 5837 5958 6661
t = rows2vars(t,VariableNamingRule="preserve")
t = 42x40 table
OriginalVariableNames Final consumption expenditure Household final consumption expenditure Goods Durable goods Semi-durable goods Non-durable goods Services Non-profit institutions serving households' final consumption e General governments final consumption expenditure Gross fixed capital formation Business gross fixed capital formation Residential structures Non-residential structures, machinery and equipment Non-residential structures Machinery and equipment Intellectual property products Non-profit institutions serving households' gross fixed capital General governments gross fixed capital formation Investment in inventories Of which: business investment in inventories Non-farm Farm Exports of goods and services Exports to other countries Exports of goods to other countries Exports of services to other countries Exports to other provinces Exports of goods to other provinces Exports of services to other provinces Less: imports of goods and services Imports from other countries Imports of goods from other countries Imports of services from other countries Imports from other provinces Imports of goods from other provinces Imports of services from other provinces Statistical discrepancy Gross domestic product at market prices Final domestic demand
_____________________ _____________________________ _______________________________________ _____ _____________ __________________ _________________ ________ _______________________________________________________________ _________________________________________________ _____________________________ ______________________________________ ______________________ ___________________________________________________ __________________________ _______________________ ______________________________ _______________________________________________________________ _________________________________________________ _________________________ ____________________________________________ ________ _____ _____________________________ __________________________ ___________________________________ ______________________________________ __________________________ ___________________________________ ______________________________________ ___________________________________ ____________________________ _____________________________________ ________________________________________ ____________________________ _____________________________________ ________________________________________ _______________________ _______________________________________ _____________________
{'1981'} 74785 49421 23172 4111 3068 17803 25632 864 25706 40943 34948 9953 22704 24940 3539 2527 127 6012 186 180 110 75 47401 15698 14281 1577 32721 22478 9397 46377 14719 11726 3154 33093 17968 15048 -1083 121088 119315
{'1982'} 74931 48922 22394 3565 2935 18175 26074 872 26571 36555 29290 7932 19227 21172 2983 2158 130 7266 -2088 -2046 -1652 -136 45593 16062 14639 1551 30082 20577 8752 40115 11879 9247 2922 29738 15679 14000 -1368 118052 114339
{'1983'} 76465 49051 22379 3689 2944 17878 26236 806 28429 29889 23914 6739 15588 16329 2645 1724 105 5978 -865 -841 -448 -466 46705 15882 14511 1463 31552 21857 8814 40284 11709 9263 2638 30143 15763 14320 465 117421 108311
{'1984'} 77002 49488 22516 3892 2952 17655 26551 760 28587 26476 21596 5201 14191 14776 2433 1973 95 4893 -870 -857 -163 -1000 49228 17851 16330 1608 31949 21897 9246 35613 11960 9607 2469 24612 12407 12155 -82 123180 105083
{'1985'} 80953 52267 23630 4451 3083 17872 28241 862 29623 28530 23269 5454 15102 16153 2463 2441 93 5284 274 273 183 83 53112 21069 19258 1925 32389 21735 9995 38399 12635 10281 2408 26875 14312 12504 -433 132159 111238
{'1986'} 81194 52806 23652 4569 3148 17551 28828 866 29185 25456 20027 5508 13408 14733 2072 1109 91 5425 1771 1732 710 1437 52010 20873 19029 1980 31441 20644 10202 40001 13147 10445 2870 28016 14623 13330 525 128432 108117
{'1987'} 82988 54011 23665 4632 3164 17420 30197 778 29966 26461 21491 6643 13635 13505 2550 1677 94 4956 -158 -154 -125 -5 55704 23330 21487 1961 32628 21340 10664 41975 13780 10872 3118 29416 14946 14404 560 130777 110982
{'1988'} 85503 55856 24456 4961 3187 17846 31253 805 30580 30375 25655 7630 16459 15293 3409 1966 99 4674 805 783 708 -105 61004 27762 25549 2357 33420 21777 10995 45755 15425 12169 3492 31583 15892 15620 1021 140853 117607
{'1989'} 88840 58133 25113 5195 3272 18142 32987 962 31413 29337 24800 8468 15294 14063 3218 1970 103 4482 115 115 -65 299 62188 28477 26633 2003 33887 22099 11134 46418 15753 12385 3625 31920 15806 16044 1053 142912 119885
{'1990'} 91375 59723 25666 5429 3325 18366 34070 1069 32271 31077 26000 8897 15682 14589 3240 2486 120 5015 -139 -140 -363 469 62612 29543 27632 2078 33235 21065 11447 47336 16462 13002 3708 32103 15408 16620 494 146131 124238
{'1991'} 90491 59054 25215 5272 3221 18237 33909 1129 31972 28850 24181 7612 14843 13694 3110 2451 128 4590 748 739 351 517 63276 31909 30129 1991 31549 19765 11060 45986 17641 13956 3941 29346 13888 15383 976 146777 121105
{'1992'} 91375 59645 25286 5211 3294 18285 34489 1204 32172 28383 23834 8816 14068 11411 3580 2169 151 4439 -1527 -1497 -859 -747 68195 37411 35208 2433 31011 19526 10795 46471 18052 14338 3959 29400 13394 15925 -152 147756 121560
{'1993'} 92701 61392 25977 5434 3394 18636 35563 1168 31557 31413 27044 8950 16074 14204 3627 3087 167 4221 863 845 -157 1570 73583 39899 37704 2461 33932 21832 11437 48308 19640 15642 4250 29535 13311 16147 -52 159234 125842
{'1994'} 93724 63784 26794 5688 3486 19110 37195 1126 29758 36162 32180 8872 19729 19137 3788 4247 151 3804 -277 -273 -306 130 78712 43747 41323 2713 35193 23218 11388 50638 19934 15580 4706 31756 15477 16135 1505 168049 131475
{'1995'} 94882 65202 27159 5733 3652 19197 38309 1216 29193 36027 32341 7820 20143 19100 4038 4691 194 3440 1584 1551 830 854 83092 48227 45564 2983 35030 23043 11392 52769 21138 16667 4796 32640 16011 16472 1090 173206 132536
{'1996'} 96845 67067 28005 6114 3770 19444 39320 1425 28870 38041 34239 8976 21127 18522 4830 4694 185 3562 -120 -116 -21 -137 90697 51695 48572 3443 39244 27627 11185 56783 24874 19915 5250 32544 15495 16939 342 177367 136502
t.Properties.RowNames = t.OriginalVariableNames; t.OriginalVariableNames = [] % Clean up the row names
t = 42x39 table
Final consumption expenditure Household final consumption expenditure Goods Durable goods Semi-durable goods Non-durable goods Services Non-profit institutions serving households' final consumption e General governments final consumption expenditure Gross fixed capital formation Business gross fixed capital formation Residential structures Non-residential structures, machinery and equipment Non-residential structures Machinery and equipment Intellectual property products Non-profit institutions serving households' gross fixed capital General governments gross fixed capital formation Investment in inventories Of which: business investment in inventories Non-farm Farm Exports of goods and services Exports to other countries Exports of goods to other countries Exports of services to other countries Exports to other provinces Exports of goods to other provinces Exports of services to other provinces Less: imports of goods and services Imports from other countries Imports of goods from other countries Imports of services from other countries Imports from other provinces Imports of goods from other provinces Imports of services from other provinces Statistical discrepancy Gross domestic product at market prices Final domestic demand
_____________________________ _______________________________________ _____ _____________ __________________ _________________ ________ _______________________________________________________________ _________________________________________________ _____________________________ ______________________________________ ______________________ ___________________________________________________ __________________________ _______________________ ______________________________ _______________________________________________________________ _________________________________________________ _________________________ ____________________________________________ ________ _____ _____________________________ __________________________ ___________________________________ ______________________________________ __________________________ ___________________________________ ______________________________________ ___________________________________ ____________________________ _____________________________________ ________________________________________ ____________________________ _____________________________________ ________________________________________ _______________________ _______________________________________ _____________________
1981 74785 49421 23172 4111 3068 17803 25632 864 25706 40943 34948 9953 22704 24940 3539 2527 127 6012 186 180 110 75 47401 15698 14281 1577 32721 22478 9397 46377 14719 11726 3154 33093 17968 15048 -1083 121088 119315
1982 74931 48922 22394 3565 2935 18175 26074 872 26571 36555 29290 7932 19227 21172 2983 2158 130 7266 -2088 -2046 -1652 -136 45593 16062 14639 1551 30082 20577 8752 40115 11879 9247 2922 29738 15679 14000 -1368 118052 114339
1983 76465 49051 22379 3689 2944 17878 26236 806 28429 29889 23914 6739 15588 16329 2645 1724 105 5978 -865 -841 -448 -466 46705 15882 14511 1463 31552 21857 8814 40284 11709 9263 2638 30143 15763 14320 465 117421 108311
1984 77002 49488 22516 3892 2952 17655 26551 760 28587 26476 21596 5201 14191 14776 2433 1973 95 4893 -870 -857 -163 -1000 49228 17851 16330 1608 31949 21897 9246 35613 11960 9607 2469 24612 12407 12155 -82 123180 105083
1985 80953 52267 23630 4451 3083 17872 28241 862 29623 28530 23269 5454 15102 16153 2463 2441 93 5284 274 273 183 83 53112 21069 19258 1925 32389 21735 9995 38399 12635 10281 2408 26875 14312 12504 -433 132159 111238
1986 81194 52806 23652 4569 3148 17551 28828 866 29185 25456 20027 5508 13408 14733 2072 1109 91 5425 1771 1732 710 1437 52010 20873 19029 1980 31441 20644 10202 40001 13147 10445 2870 28016 14623 13330 525 128432 108117
1987 82988 54011 23665 4632 3164 17420 30197 778 29966 26461 21491 6643 13635 13505 2550 1677 94 4956 -158 -154 -125 -5 55704 23330 21487 1961 32628 21340 10664 41975 13780 10872 3118 29416 14946 14404 560 130777 110982
1988 85503 55856 24456 4961 3187 17846 31253 805 30580 30375 25655 7630 16459 15293 3409 1966 99 4674 805 783 708 -105 61004 27762 25549 2357 33420 21777 10995 45755 15425 12169 3492 31583 15892 15620 1021 140853 117607
1989 88840 58133 25113 5195 3272 18142 32987 962 31413 29337 24800 8468 15294 14063 3218 1970 103 4482 115 115 -65 299 62188 28477 26633 2003 33887 22099 11134 46418 15753 12385 3625 31920 15806 16044 1053 142912 119885
1990 91375 59723 25666 5429 3325 18366 34070 1069 32271 31077 26000 8897 15682 14589 3240 2486 120 5015 -139 -140 -363 469 62612 29543 27632 2078 33235 21065 11447 47336 16462 13002 3708 32103 15408 16620 494 146131 124238
1991 90491 59054 25215 5272 3221 18237 33909 1129 31972 28850 24181 7612 14843 13694 3110 2451 128 4590 748 739 351 517 63276 31909 30129 1991 31549 19765 11060 45986 17641 13956 3941 29346 13888 15383 976 146777 121105
1992 91375 59645 25286 5211 3294 18285 34489 1204 32172 28383 23834 8816 14068 11411 3580 2169 151 4439 -1527 -1497 -859 -747 68195 37411 35208 2433 31011 19526 10795 46471 18052 14338 3959 29400 13394 15925 -152 147756 121560
1993 92701 61392 25977 5434 3394 18636 35563 1168 31557 31413 27044 8950 16074 14204 3627 3087 167 4221 863 845 -157 1570 73583 39899 37704 2461 33932 21832 11437 48308 19640 15642 4250 29535 13311 16147 -52 159234 125842
1994 93724 63784 26794 5688 3486 19110 37195 1126 29758 36162 32180 8872 19729 19137 3788 4247 151 3804 -277 -273 -306 130 78712 43747 41323 2713 35193 23218 11388 50638 19934 15580 4706 31756 15477 16135 1505 168049 131475
1995 94882 65202 27159 5733 3652 19197 38309 1216 29193 36027 32341 7820 20143 19100 4038 4691 194 3440 1584 1551 830 854 83092 48227 45564 2983 35030 23043 11392 52769 21138 16667 4796 32640 16011 16472 1090 173206 132536
1996 96845 67067 28005 6114 3770 19444 39320 1425 28870 38041 34239 8976 21127 18522 4830 4694 185 3562 -120 -116 -21 -137 90697 51695 48572 3443 39244 27627 11185 56783 24874 19915 5250 32544 15495 16939 342 177367 136502
3 件のコメント
Ezra
2024 年 8 月 7 日
I like this! Thank you very much Siddharth. I'm learning more about how to use readtable with each comment, so it's much appreciated!
Steven Lord
2024 年 8 月 7 日
Another tool that may be able to help you is the Import Tool. This allows you to interactively experiment with how MATLAB will import your data, changing the data types of the variables it will import, control how unimportable cells are handled, etc. Once you're satisfied with your selections you can import the data and/or generate a script or function. [You can also iterate based on whether or not the imported data looks the way you want it to.]
The generated code can help you learn more about the commands MATLAB used to import the data and/or allow you to import more files in the same format without having to repeat the interactive configuration.
In this case, the commas in (some of) your numbers are interpreted as thousands separators (so 74,785 is interpreted as seventy-four thousand, seven hundred eighty-five) rather than as the decimal separator. If that's correct then you should be okay. If not, I don't think Import Tool has an option to specify what the decimal separator is but if that's a common situation for your data, you could file an enhancement request for such an option with Technical Support directly using this link.
Ezra
2024 年 8 月 7 日
Thank you! In the future I'll likely try the import tools rather than coding directly. I figure I could learn a lot from it.
The commas are indeed thousands seperators (luckily)!
参考
カテゴリ
Help Center および File Exchange で Text Files についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
アジア太平洋地域
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)