Modify then write data in the given format
Al momento, stai seguendo questa domanda
- Vedrai gli aggiornamenti nel tuofeed del contenuto seguito.
- Potresti ricevere delle e-mail a seconda delle tuepreferenze per le comunicazioni.
Si è verificato un errore
Impossibile completare l'azione a causa delle modifiche apportate alla pagina. Ricarica la pagina per vedere lo stato aggiornato.
0 voti
Condividi un link a questa domanda
1 Commento
Condividi un link a questo commento
Risposta accettata
0 voti
Condividi un link a questa risposta
- Read the first three columns to one string, since they shall only be copied to the output file.
- Read the following six columns to a double array.
- Add 1 to the prescribed elements of the array
- Use the same format string to write the data (don't forget new-line)
27 Commenti
Condividi un link a questo commento
Condividi un link a questo commento
Condividi un link a questo commento
- It's possible to read your example with textscan and a similar format specifier - see my addendum. Or are we speaking past each other?
- Can we be sure that "undocumented" behavior of textscan doesn't change between releases?
- "Somewhere some months ago"   might be this thread read ascii non-delimited file.
- "older Fortran and are still around"   that's true and most large "csv-files" contains fixed-width columns. Long time ago reading fixed-format text-files was much faster than reading free-format. Is that still the case?
- Rows with leading spaces causes problems. '%s' handles it, but '%f' doesn't.
Condividi un link a questo commento
Condividi un link a questo commento
Condividi un link a questo commento
Condividi un link a questo commento
Condividi un link a questo commento
Condividi un link a questo commento
Condividi un link a questo commento
Condividi un link a questo commento
Condividi un link a questo commento
Condividi un link a questo commento
Condividi un link a questo commento
Condividi un link a questo commento
- Regarding the documentation in general I think that it's okay and is being improved over time. However, I've have wishes. More elaborated problem oriented examples, e.g. "How to read fixed width text file" and "How to read multi-section text files". Easier to find a function when I forgotten the name. And more.
- textscan   Knowledge on C might helps to understand why, but must not be required. (If needed that should be clearly stated.) Regarding 'Delimiter','' and 'Whitespace','' I still think they don't cause the promised behavior. Recently, I read some documentation on Fortran format specifiers. We only want a small subset.
- The documentation of the low-level HDF5-functions is another example of referring to third party documentation. In this case I think it is okay.
- The documentation on Regular expressions is okay I think. However, I think more elaborated examples would be useful.
Condividi un link a questo commento
Condividi un link a questo commento
Condividi un link a questo commento
- the first one (with commas) is the best (i.e. most readable) and
- that something like this would fit better in the Matlab environment than a syntax, which mimics fortrans FORMAT
Condividi un link a questo commento
Condividi un link a questo commento
- Sure, it's just "syntactic sugar".
- Maybe, a syntax like this would be enough (with a fortran engine)
- I don't understand TMW
Condividi un link a questo commento
Condividi un link a questo commento
- reading with textscan together with a format-string based entirely on %wc where w is a whole number
- format-string according to my comment above
- converting to numerical in a second step - maybe with str2num.
- do some timing experiments
- Is there a need for a new function to read fixed-formatted text files?
- Does my prototype handle the most frequent types of fixed-width files?
- A good fortran-mex-function, how much faster would that be?
Condividi un link a questo commento
Condividi un link a questo commento
Condividi un link a questo commento
- On input, the F data edit descriptor transfers w characters from an external field and assigns their real value to the corresponding I/O list item. The external field data must be an integer or real constant.
- If the input field contains only an exponent letter or decimal point, it is treated as a zero value.
- If the input field does not contain a decimal point or an exponent, it is treated as a real number of w digits, with d digits to the right of the decimal point. (Leading zeros are added, if necessary.)
- If the input field contains a decimal point, the location of that decimal point overrides the location specified by the F descriptor.
- If the field contains an exponent, that exponent is used to establish the magnitude of the value before it is assigned to the list element.
- An explicit 1X to skip the delimiter, or
- A compiler-dependent extension that recognizes the comma as a delimiter(*)
Condividi un link a questo commento
Condividi un link a questo commento
- Nobody would read them, and
- It would take a "language lawyer" to parse the result in the exotic cases if did.
Più risposte (0)
Categorie
Scopri di più su Sudoku in Centro assistenza e File Exchange
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Seleziona un sito web
Seleziona un sito web per visualizzare contenuto tradotto dove disponibile e vedere eventi e offerte locali. In base alla tua area geografica, ti consigliamo di selezionare: .
Puoi anche selezionare un sito web dal seguente elenco:
Come ottenere le migliori prestazioni del sito
Per ottenere le migliori prestazioni del sito, seleziona il sito cinese (in cinese o in inglese). I siti MathWorks per gli altri paesi non sono ottimizzati per essere visitati dalla tua area geografica.
Americhe
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- 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)
