Modify then write data in the given format
Vous suivez désormais cette question
- Les mises à jour seront visibles dans votre flux de contenu suivi.
- Selon vos préférences en matière de communication il est possible que vous receviez des e-mails.
Une erreur s'est produite
Impossible de terminer l’action en raison de modifications de la page. Rechargez la page pour voir sa mise à jour.
0 votes
Partagez un lien vers cette question
1 commentaire
Partagez un lien vers ce commentaire
Réponse acceptée
0 votes
Partagez un lien vers cette réponse
- 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 commentaires
Partagez un lien vers ce commentaire
Partagez un lien vers ce commentaire
Partagez un lien vers ce commentaire
- 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.
Partagez un lien vers ce commentaire
Partagez un lien vers ce commentaire
Partagez un lien vers ce commentaire
Partagez un lien vers ce commentaire
Partagez un lien vers ce commentaire
Partagez un lien vers ce commentaire
Partagez un lien vers ce commentaire
Partagez un lien vers ce commentaire
Partagez un lien vers ce commentaire
Partagez un lien vers ce commentaire
Partagez un lien vers ce commentaire
Partagez un lien vers ce commentaire
- 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.
Partagez un lien vers ce commentaire
Partagez un lien vers ce commentaire
Partagez un lien vers ce commentaire
- 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
Partagez un lien vers ce commentaire
Partagez un lien vers ce commentaire
- Sure, it's just "syntactic sugar".
- Maybe, a syntax like this would be enough (with a fortran engine)
- I don't understand TMW
Partagez un lien vers ce commentaire
Partagez un lien vers ce commentaire
- 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?
Partagez un lien vers ce commentaire
Partagez un lien vers ce commentaire
Partagez un lien vers ce commentaire
- 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(*)
Partagez un lien vers ce commentaire
Partagez un lien vers ce commentaire
- Nobody would read them, and
- It would take a "language lawyer" to parse the result in the exotic cases if did.
Plus de réponses (0)
Catégories
En savoir plus sur Sudoku dans Centre d'aide et File Exchange
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.
Amériques
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)
