IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

 C Discussion :

conversion d'un fichier .wlk vers fichier .txt


Sujet :

C

  1. #1
    Nouveau membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2012
    Messages
    60
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Décembre 2012
    Messages : 60
    Points : 27
    Points
    27
    Par défaut conversion d'un fichier .wlk vers fichier .txt
    Bonjour,

    j'ai un tres gro souci qui est de convertir un fichier d'extension ".wlk" vers un fichier .txt.
    Svp, ya t'il quelqu'un qui peut m'aider?

  2. #2
    Modérateur
    Avatar de Obsidian
    Homme Profil pro
    Développeur en systèmes embarqués
    Inscrit en
    Septembre 2007
    Messages
    7 372
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Développeur en systèmes embarqués
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2007
    Messages : 7 372
    Points : 23 628
    Points
    23 628
    Par défaut
    C'est un fichier qui provient de quel logiciel ?

  3. #3
    Nouveau membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2012
    Messages
    60
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Décembre 2012
    Messages : 60
    Points : 27
    Points
    27
    Par défaut
    slt,

    c'est un fichier qui provient d'un logiciel appélé weatherlink. ce logiciel permet de copier ces fichiers ".wlk" en fichiers textes ( manuellement) sauf que moi j'ai besoins du code pour automatiser le stockage des données non pas en fichier ".wlk" (comme le fait weatherlink) mais en fichier ".txt"

  4. #4
    Membre expérimenté Avatar de Ngork
    Homme Profil pro
    Barbare IT
    Inscrit en
    Avril 2009
    Messages
    160
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Barbare IT
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2009
    Messages : 160
    Points : 1 372
    Points
    1 372
    Par défaut
    Normalement, il y a un fichier descriptif du format dans le fichier readme.rtf (ou readme.wri pour les versions plus anciennes) à la racine du répertoire de l'application ...

  5. #5
    Membre expérimenté Avatar de Ngork
    Homme Profil pro
    Barbare IT
    Inscrit en
    Avril 2009
    Messages
    160
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Barbare IT
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2009
    Messages : 160
    Points : 1 372
    Points
    1 372
    Par défaut extrait du fichier descriptif (en anglais)
    Data File Structure

    What follows is a technical description of the .WLK weather database files. This is of interest mostly to programmers who want to write their own programs to read the data files.

    The data filename has the following format: YYYY-MM.wlk where YYYY is the four digit year and MM is the two digit month of the data contained in the file.

    The structures defined below assume that no bytes are added to the structures to make the fields are on the "correct" address boundaries. With the Microsoft C++ compiler, you can use the directive "#pragma pack (1)" to enforce this and use "#pragma pack ()" to return the compiler to its default behavior.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    //   Data is stored in monthly files.  Each file has the following header.
    struct DayIndex 
    {
       short recordsInDay;  // includes any daily summary records
       long startPos;    // The index (starting at 0) of the first daily summary record
    };      
     
    // Header for each monthly file.
    // The first 16 bytes are used to identify a weather database file and to identify
    //   different file formats. (Used for converting older database files.)
    class HeaderBlock
    { 
       char idCode [16]; // = {'W', 'D', 'A', 'T', '5', '.', '0', 0, 0, 0, 0, 0, 0, 0, 5, 0}
       long totalRecords;
       DayIndex dayIndex [32]; // index records for each day. Index 0 is not used
                               // (i.e. the 1'st is at index 1, not index 0)
    };
     
    // After the Header are a series of 88 byte data records with one of the following
    //   formats.  Note that each day will begin with 2 daily summary records
     
    // Daily Summary Record 1
    struct DailySummary1
    {
       BYTE dataType = 2;
       BYTE reserved;    // this will cause the rest of the fields to start on an even address
     
       short dataSpan;   // total # of minutes accounted for by physical records for this day
       short hiOutTemp, lowOutTemp; // tenths of a degree F
       short hiInTemp, lowInTemp;   // tenths of a degree F
       short avgOutTemp, avgInTemp; // tenths of a degree F (integrated over the day)
       short hiChill, lowChill;     // tenths of a degree F
       short hiDew, lowDew;         // tenths of a degree F
       short avgChill, avgDew;      // tenths of a degree F 
       short hiOutHum, lowOutHum;   // tenths of a percent
       short hiInHum, lowInHum;     // tenths of a percent
       short avgOutHum;             // tenths of a percent
       short hiBar, lowBar;         // thousandths of an inch Hg
       short avgBar;                // thousandths of an inch Hg
       short hiSpeed, avgSpeed;     // tenths of an MPH
       short dailyWindRunTotal;     // 1/10'th of an mile 
       short hi10MinSpeed;          // the highest average wind speed record 
       BYTE  dirHiSpeed, hi10MinDir; // direction code (0-15, 255)
       short dailyRainTotal;        // 1/1000'th of an inch
       short hiRainRate;            // 1/100'th inch/hr ???
       short dailyUVDose;           // 1/10'th of a standard MED
       BYTE  hiUV;                  // tenth of a UV Index
       BYTE timeValues[27];         // space for 18 time values (see below)
    };  
     
    // Daily Summary Record 2
    struct DailySummary2
    {
       BYTE dataType = 3;
       BYTE  reserved;   // this will cause the rest of the fields to start on an even address
     
       // this field is not used now.
       unsigned short todaysWeather; // bitmapped weather conditions (Fog, T-Storm, hurricane, etc)
     
       short numWindPackets;      // # of valid packets containing wind data, 
                                  // this is used to indicate reception quality
       short hiSolar;             // Watts per meter squared
       short dailySolarEnergy;    // 1/10'th Ly
       short minSunlight;         // number of accumulated minutes where the avg solar rad > 150
       short dailyETTotal;        // 1/1000'th of an inch
       short hiHeat, lowHeat;     // tenths of a degree F
       short avgHeat;             // tenths of a degree F
       short hiTHSW, lowTHSW;     // tenths of a degree F
       short hiTHW, lowTHW;       // tenths of a degree F
     
       short integratedHeatDD65;  // integrated Heating Degree Days (65F threshold)
                                  // tenths of a degree F - Day
     
       // Wet bulb values are not calculated
       short hiWetBulb, lowWetBulb; // tenths of a degree F
       short avgWetBulb;          // tenths of a degree F
     
       BYTE dirBins[24];          // space for 16 direction bins 
                                  // (Used to calculate monthly dominant Dir)
     
       BYTE timeValues[15];       // space for 10 time values (see below)
     
       short integratedCoolDD65;  // integrated Cooling Degree Days (65F threshold)
                                  // tenths of a degree F - Day
       BYTE  reserved2[11];
    };
     
    // standard archive record
    struct WeatherDataRecord
    {
       BYTE dataType = 1;
       BYTE archiveInterval;      // number of minutes in the archive
       // see below for more details about these next two fields)
       BYTE iconFlags;            // Icon associated with this record, plus Edit flags
       BYTE moreFlags;            // Tx Id, etc.
     
       short packedTime;          // minutes past midnight of the end of the archive period
       short outsideTemp;         // tenths of a degree F
       short hiOutsideTemp;       // tenths of a degree F
       short lowOutsideTemp;      // tenths of a degree F
       short insideTemp;          // tenths of a degree F
       short barometer;           // thousandths of an inch Hg
       short outsideHum;          // tenths of a percent
       short insideHum;           // tenths of a percent
       unsigned short rain;       // number of clicks + rain collector type code
       short hiRainRate;          // clicks per hour
       short windSpeed;           // tenths of an MPH
       short hiWindSpeed;         // tenths of an MPH
       BYTE windDirection;        // direction code (0-15, 255)
       BYTE hiWindDirection;      // direction code (0-15, 255)
       short numWindSamples;      // number of valid ISS packets containing wind data
                                  // this is a good indication of reception 
       short solarRad, hisolarRad;// Watts per meter squared 
       BYTE  UV, hiUV;            // tenth of a UV Index
     
       BYTE leafTemp[4];          // (whole degrees F) + 90
     
       short extraRad;            // used to calculate extra heating effects of the sun in THSW index
     
       short newSensors[6];       // reserved for future use
       BYTE  forecast;            // forecast code during the archive interval
     
       BYTE  ET;                  // in thousandths of an inch
     
       BYTE soilTemp[6];          // (whole degrees F) + 90
       BYTE soilMoisture[6];      // centibars of dryness
       BYTE leafWetness[4];       // Leaf Wetness code (0-15, 255)
       BYTE extraTemp[7];         // (whole degrees F) + 90
       BYTE extraHum[7];          // whole percent
    };

  6. #6
    Nouveau membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2012
    Messages
    60
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Décembre 2012
    Messages : 60
    Points : 27
    Points
    27
    Par défaut
    merci pour votre aide, donc je comprend que ce code contient la partie ou ya la conversion? je ne trouve pas. ou est ce que c'est just un morceau du code?

  7. #7
    Modérateur
    Avatar de Obsidian
    Homme Profil pro
    Développeur en systèmes embarqués
    Inscrit en
    Septembre 2007
    Messages
    7 372
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Développeur en systèmes embarqués
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Septembre 2007
    Messages : 7 372
    Points : 23 628
    Points
    23 628
    Par défaut
    Pas tout-à-fait :

    Ce code définit des structures en C qui permettent d'organiser des données exactement de la manière dont elles le sont dans ton fichier initial.

    Si tu charges son contenu dans ces structures, tu peux ensuite accéder facilement à chaque membre et, de là, faire des « printf » de ces valeurs pour les écrire en clair à l'écran ou dans un fichier de destination.

    Par ailleurs, tu as déposé ta question dans le forum C. On t'a donc donné une solution en langage C.

  8. #8
    Nouveau membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2012
    Messages
    60
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Décembre 2012
    Messages : 60
    Points : 27
    Points
    27
    Par défaut
    Bonjour,
    je n'arrive pas à comprendre comment charger son contenu sur cette structure, je trrouve ou ce contenu la? pouvez vous m'expliquer? svp

  9. #9
    Membre expérimenté Avatar de Ngork
    Homme Profil pro
    Barbare IT
    Inscrit en
    Avril 2009
    Messages
    160
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Barbare IT
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2009
    Messages : 160
    Points : 1 372
    Points
    1 372
    Par défaut
    Il suffit de lire les structures, qui sont très bien commentées :

    Chaque fichier mensuel commence par une structure HeaderBlock.

    Un HeaderBlock est d'abord composé d'un idCode de 16 octets qui permet de déterminer la version de la base WeatherLink, par exemple : la chaîne "WDAT5.0" suivie de 8 octets dont la signification n'est pas précisée mais qui se rapportent aussi à la version.
    Ce HeaderBlock comporte ensuite un entier long totalRecords qui indique le nombre total d'enregistrements que l'on va trouver dans le fichier.
    Enfin, le HeaderBlock contient 32 structures DayIndex, dont chacune te donne pour le jour du mois correspondant un entier court recordsInDay, soit le nombre d'enregistrements du jour, et la position de départ startPos du premier enregistrement du jour.

    Après le HeaderBlock, tu trouveras donc les enregistrements eux-mêmes, soit des blocs de 88 octets correspondant soit à la structure DailySummary1 soit à la structure DailySummary2, et il te faut tester le premier octet (égal à 2 ou 3) pour savoir quelle est la bonne structure à appliquer.

    Il te suffit donc de réserver une structure HeaderBlock, d'ouvrir le fichier en lecture, de lire autant d'octets qu'en réclame ta structure (sizeof) et de coller ce qui a été lu dans la structure.
    Tu peux ensuite lire chaque bloc DailySummary avec une boucle sur totalRecords, ou bien boucler sur chaque jour et le nombre d'enregistrements pour ce jour ...

    Maintenant, sauf à écrire à ta place le programme (ce qui n'est pas le but de ce forum), je ne vois pas ce que je peux t'expliquer de plus ...

  10. #10
    Nouveau membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2012
    Messages
    60
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Décembre 2012
    Messages : 60
    Points : 27
    Points
    27
    Par défaut
    je ne suis pas informaticien et j'ai jamais eu à créer un logiciel, j'ai cogné sur une contrainte que je dois résoudre d'une maniere ou d'une autre, vous m'avez indiquez une source à exploiter , je vous remerci infiniment, je vais essayer de comprendre cette structure en suivant vos indications, et si je bloque quelque part je vous tiendrai au courant.

  11. #11
    Membre expérimenté Avatar de Ngork
    Homme Profil pro
    Barbare IT
    Inscrit en
    Avril 2009
    Messages
    160
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loire Atlantique (Pays de la Loire)

    Informations professionnelles :
    Activité : Barbare IT
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2009
    Messages : 160
    Points : 1 372
    Points
    1 372
    Par défaut
    Oui, évidemment, si tu n'es pas informaticien, et donc pas développeur professionnel, ni même développeur amateur, je crains que ce forum ne soit vraiment pas adapté à ton problème !
    En gros, il te faut soit trouver un logiciel qui fait déjà ce travail de conversion automatique des fichiers .wlk en fichiers .txt, soit trouver un développeur qui dispose du temps et de l'envie de développer ce logiciel pour toi ...
    Ou alors, il faut que tu deviennes toi-même développeur !
    Quel que soit ton choix, je te souhaite bonne chance !

  12. #12
    Nouveau membre du Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2012
    Messages
    60
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Algérie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Décembre 2012
    Messages : 60
    Points : 27
    Points
    27
    Par défaut
    merci pour vos précie8 conseils,

  13. #13
    Futur Membre du Club
    Profil pro
    Inscrit en
    Décembre 2009
    Messages
    2
    Détails du profil
    Informations personnelles :
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations forums :
    Inscription : Décembre 2009
    Messages : 2
    Points : 5
    Points
    5
    Par défaut
    Bonjour,

    Pour répondre à la question,
    un programme permettant de recoder le format wlk vers des formats texte (csv, html ou sql) est maintenant disponible ici :
    http://meteofrouzins.fr/wlktransformer.php

Discussions similaires

  1. Conversion fichier Excel vers fichier PDF sur Mac
    Par Invité dans le forum Documents
    Réponses: 19
    Dernier message: 19/02/2015, 14h57
  2. Extraction de données d'un fichier excel vers un .TXT
    Par titi_rugby dans le forum Macros et VBA Excel
    Réponses: 2
    Dernier message: 28/02/2012, 16h40
  3. Conversion fichier flv vers fichier mp3
    Par Sinari dans le forum C++
    Réponses: 5
    Dernier message: 26/10/2011, 19h30
  4. fichier binaire vers fichier ascii.
    Par vbk!!! dans le forum Général Python
    Réponses: 3
    Dernier message: 24/09/2008, 12h17
  5. Recopier fichier ANSI vers fichier Unicode
    Par Aka Guymelef dans le forum Contribuez
    Réponses: 1
    Dernier message: 17/03/2008, 13h51

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo