Import Fitbit Aria Scale Info

Partner Apps
Answered

Comments

  • jencharls878
    0

    likes

    I think the only data that can be imported from Fitbit are steps and not the weight measurements. For more information, you can visit this article that I saw in the Help Center: https://support.withings.com/hc/en-us/articles/115015704668-Partner-Apps-What-is-Fitbit-. I hope this helps.

    0

    likes

  • lmalossi
    0

    likes

    really there isn't a way to import weight from Aria to Healthmate?

    0

    likes

  • toddbelt
    0

    likes

    Could someone from WIthings Support please respond here?  If it is bad news, then so be it, but to say nothing is either lazy or a coverup.  

    0

    likes

  • quicksand10
    10

    likes

    No response from Withings Support?

     

    EDIT: So I found a way to import ALL historical Fitbit Aria data to Withings, but it's not pretty.

    It involves (1) getting all your Fitbit data, (2) merging the weight data into a single JSON file, (3) converting the JSON to CSV, (4) cleaning up the CSV data into a format Withings can read and finally (5) importing the data.

    Required tools:

    - Your Fitbit historical data account archive (link)

    - Access to a Linux machine with jq installed (link) (NOTE: this will not work with Windows jq, but it worked with me through Ubuntu - Windows Subsystem for Linux).

    Steps:

    1. Extract your Fitbit account archive.

    2. In the subfolder called "user-site-export", copy all "weight-yyyy-mm-dd.json" files to a new folder called "weight".

    3. In a bash command prompt, navigate to your "weight" folder and input the following command: jq -n "[inputs] | add" *.json > output.json

    4. You now have one single file with all your weight data. Open this new output.json file in a text editor (like Notepad++ (link)) and copy the content of this file to the clipboard.

    5. Paste the contents of your clipboard into the the JSON to CSV online converter found at https://konklone.io/json/ (link), which is free and open-source (link) (no privacy concerns, conversion happens inside the browser).

    6. Download this new CSV file to your computer and name it "original.csv". Make a copy called "for-import.csv".

    7. Your data needs to have the following columns in this order: date (yyyy-mm-dd), weight, fat. You can edit for-import.csv in Microsoft Excel or LibreOffice Calc (link).

    8. Follow the instructions for Importing data into Withings (link). Insure that the measurement units in your file match the ones in your Withings profile.

    On top of all this, you may need to split your resulting CSV in multiple files, since Withings only supports uploading up to 300-lines at a time in a single CSV. Simply split your for-import.csv into multiple files and import them one at a time.

    Hope this helps someone!

    10

    likes

  • zahra.amir
    0

    likes

    Thank you so much for the detailed steps! I used this to transfer years worth of data from my Aria scale. The only issue is in their fat measurements they are most likely using a different unit. 

    Again thanks a lot for sharing your steps! :)

    0

    likes

  • Rob R
    0

    likes

    It looks like it is not in percentage, likely that is the case. 

    From the import screen:

    These are the expected columns:

    • Date
    • Weight
    • Fat mass (optional - format : kg)

    Examples:

    • 2013-02-22 08:33:00, 68.5
    • 2013-02-22 08:33:00, 68.5, 12
    • 2013-02-22 08:33:00, 11:10, 17

     

    Of course, then it says the following (emphasis mine):

     

    • File must be in a CSV format with commas as column separators and without field separators
    • File must have a header
    • Values must be in US numbers format (with a point as decimal mark)
    • Date must be in yyyy-mm-dd hh:mm:ss format (example: 2013-11-22 08:35:00)
    • Numerical values must be in the same unit set in your dashboard
    • Do not exceed 300 rows in a file

    So I'm guessing you would need to convert the percentage to an actual weight amount (lbs for me instead of kg since I'm in the US). 

    I'm going to create a test import first (one data point) to make sure it's all working.

    0

    likes

  • Rob R
    2

    likes

    So I wrote a PowerShell function, which you can use on Windows, Mac, or anywhere you can install PowerShell.

    This involves extracting your Fitbit data, then pointing this function at the folder that has the "weight-yyyy-mm-dd.json" files in it. Then you just need to import the resulting files into Withings. 

    1. Extract your Fitbit Data Export (make sure you export all data).

    2. Save the following as Convert-FitbitToWithingsWeightMeasurements.ps1:

    Function Convert-FitbitToWithingsWeightMeasurements {
      [CmdletBinding()]
      Param(
        [Parameter()]
        [String]
        $Folder =(Get-Location).Path
      )

      # Create a collection (a List for memory efficiency) to hold output
      $WithingsWeightMeasurements = New-Object System.Collections.Generic.List[System.Object]

    # Search for all files that start with "weight" and end with ".json"
      $JsonFilesCount = 0
      $WeightMeasurementsCount = 0
      Get-ChildItem $Folder -Filter weight-*.json |
      Foreach-Object {
        $JsonFilesCount += 1
        # Get JSON content and then add them to the collection
        Get-Content $_.FullName | Out-String | ConvertFrom-Json | ForEach-Object {
          $WeightMeasurementsCount += 1
          $WithingsWeightMeasurements.Add([PSCustomObject]@{
            Date = $([DateTime]$_.date).ToString('yyyy-MM-dd') + " " + $([DateTime]$_.time).ToString("hh:mm:ss")
            Weight = $_.weight
          FatMass = if($_.fat -le 1) {""} else {[Math]::Round(($_.weight * ($_.fat / 100)),2)}
          }) | Out-Null
          # - Date must be in yyyy-mm-dd hh:mm:ss format (example: 2013-11-22 08:35:00)
          # - Values must be in US numbers format (with a point as decimal mark)
          # - Numerical values must be in the same unit set in your dashboard
          # - Fat mass (optional - format : kg) (OR 'lb' based on "same unit set in your dashboard")
          # Fat isn't always available from Fitbit either
        }
      }

      # - Do not exceed 300 rows in a file
      # Split to 299 value arrays
      $ImportSizeLimit = 299

      Write-Host "Captured $WeightMeasurementsCount weight measurements from $JsonFilesCount exported Fitbit files. Splitting data to $ImportSizeLimit batches for import."

      $WeightMeasurementImportFiles = New-Object System.Collections.ArrayList
      $WeightItemsTemp = New-Object System.Collections.ArrayList
      $WithingsWeightMeasurements | ForEach-Object {
        $WeightItemsTemp.Add($_) | Out-Null
        If ($WeightItemsTemp.Count -ge $ImportSizeLimit) {
          $WeightMeasurementImportFiles.Add($WeightItemsTemp.ToArray()) | Out-Null
          $WeightItemsTemp.Clear()
        }
      }

      # Capture the last set of items
      if ($WeightItemsTemp.Count -gt 0) {
        $WeightMeasurementImportFiles.Add($WeightItemsTemp.ToArray()) | Out-Null
        $WeightItemsTemp.Clear()
      }

      # Create output folder
      $OutputFolder = Join-Path -Path (Get-Location).Path -ChildPath "FilesToImport"
      If (-Not (Test-Path -Path $OutputFolder)) {
        Write-Host "- Creating folder for generated files at $OutputFolder"
        New-Item -Path $OutputFolder -ItemType Directory | Out-Null
      }

      # Write each file
      for ($i = 0; $i -lt $WeightMeasurementImportFiles.Count; $i++) {
        $WeightMeasurementImportFilePath = Join-Path -Path $OutputFolder -ChildPath "Withings-Weight-Import-$i.csv"
        Write-Host "- Exporting $($i+1)/$($WeightMeasurementImportFiles.Count) weight measurement import batches to $WeightMeasurementImportFilePath."
        # - File must have a header
        # - File must be in a CSV format with commas as column separators and without field separators
        $WeightMeasurementImportFiles[$i] | Export-Csv $WeightMeasurementImportFilePath -NoTypeInformation -Force -Delimiter ',' -UseQuotes Never
      }

      Write-Host "Conversion of Fitbit data complete. Please see instructions at https://support.withings.com/hc/en-us/articles/201491477-Health-Mate-Online-Dashboard-Importing-data for importing."

    }

    That came out okay, but in case it gets weird, I also put it at https://gist.github.com/ferventcoder/f2e4df46977c52feae7c95579adc4728.

    3. Open a terminal/command line/shell and get into PowerShell. 

    4. Find the folder where you saved the Convert-FitbitToWithingsWeightMeasurements.ps1 file.

    5. Run `. Convert-FitbitToWithingsWeightMeasurements.ps1`. This dot sources the file so we can run the function.

    6. Now run `Convert-FitbitToWithingsWeightMeasurements folder\location\of\weight\json\files`. Be sure this is to a FOLDER and not a file. 

    7. Import the resulting files to Withings following the instructions at https://support.withings.com/hc/en-us/articles/201491477-Health-Mate-Online-Dashboard-Importing-data. 

     

    Below is the output for when I ran my files through for conversion. Hope this is helpful for folks who might happen across this. Thanks @quicksand10 for the starter to see this is possible! 

    PS /code/FitbitToWithingsWeightConversion> . ./Convert-FitbitToWithingsWeightMeasurements.ps1
    PS /code/FitbitToWithingsWeightConversion> Convert-FitbitToWithingsWeightMeasurements ./ImportDataOriginal/
    Captured 1898 weight measurements from 82 exported Fitbit files. Splitting data to 299 batches for import.
    - Exporting 1/7 weight measurement import batches to /Users/rob/code/mine/FitbitToWithingsWeightConversion/FilesToImport/Withings-Weight-Import-0.csv.
    - Exporting 2/7 weight measurement import batches to /Users/rob/code/mine/FitbitToWithingsWeightConversion/FilesToImport/Withings-Weight-Import-1.csv.
    - Exporting 3/7 weight measurement import batches to /Users/rob/code/mine/FitbitToWithingsWeightConversion/FilesToImport/Withings-Weight-Import-2.csv.
    - Exporting 4/7 weight measurement import batches to /Users/rob/code/mine/FitbitToWithingsWeightConversion/FilesToImport/Withings-Weight-Import-3.csv.
    - Exporting 5/7 weight measurement import batches to /Users/rob/code/mine/FitbitToWithingsWeightConversion/FilesToImport/Withings-Weight-Import-4.csv.
    - Exporting 6/7 weight measurement import batches to /Users/rob/code/mine/FitbitToWithingsWeightConversion/FilesToImport/Withings-Weight-Import-5.csv.
    - Exporting 7/7 weight measurement import batches to /Users/rob/code/mine/FitbitToWithingsWeightConversion/FilesToImport/Withings-Weight-Import-6.csv.
    Conversion of Fitbit data complete. Please see instructions at https://support.withings.com/hc/en-us/articles/201491477-Health-Mate-Online-Dashboard-Importing-data for importing.
    2

    likes

  • Alexey V
    0

    likes

    Seriously, Thank you, Rob. Goodby to Fitbit and Google Fit.

    Your script helped me a lot. Just one comment for future users: switch your Withings account to pounds, as the CSV comes in pounds. (Or you will have to clean up 10 years of being twice your weight as I had.)

    0

    likes

  • Craig B
    0

    likes

    Rob, thanks for your effort on this!
    I just got a new scale for Christmas, and it appears that FitBit has changed the output format of their files.

    The date is formatted as "mm/dd/yy" so the PowerShell script is not running. Do you have a simple fix for the script that can convert the date correctly?

    PS C:\temp> Convert-FitbitToWithingsWeightMeasurements ./FitBit/
    Cannot convert the "System.Object[]" value of type "System.Object[]" to type "System.DateTime".
    At C:\temp\Convert-FitbitToWithingsWeightMeasurements.ps1:22 char:18
    +         Date = $([DateTime]$_.date).ToString('yyyy-MM-dd') + " " + $( ...
    +                  ~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidArgument: (:) [], RuntimeException
        + FullyQualifiedErrorId : ConvertToFinalInvalidCastException

    You cannot call a method on a null-valued expression.
    At C:\temp\Convert-FitbitToWithingsWeightMeasurements.ps1:22 char:18
    +         Date = $([DateTime]$_.date).ToString('yyyy-MM-dd') + " " + $( ...
    +                  ~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : InvokeMethodOnNull
    0

    likes

  • Rob R
    0

    likes

    Hi Craig,
    That's the same format I've seen - the script converts the date from the file to the required format.

    I think you might want to take a peek at the JSON files - the error it is reporting null valued output (no value to use for conversion). What do the lines with dates have for the name? Is it "date: mm/dd/yy" where mm/dd/yy represents an actual date value?

    0

    likes

  • Craig B
    0

    likes

    All the files look like this:

    [{
      "logId" : 1703663764000,
      "weight" : 180.9,
      "bmi" : 25.34,
      "fat" : 24.985000610351562,
      "date" : "12/27/23",
      "time" : "07:56:04",
      "source" : "Aria"
    },{
      "logId" : 1703749321000,
      "weight" : 180.1,
      "bmi" : 25.23,
      "fat" : 25.007999420166016,
      "date" : "12/28/23",
      "time" : "07:42:01",
      "source" : "Aria"
    },{
    0

    likes

  • Rob R
    0

    likes

    That looks correct. I wonder if there are any empty records in any of the files?

    Maybe copy one of the files to a separate folder and then call that folder as the path and see how it handles it. Then put in another file and run it. Keep going until you find the issue.

    Also make sure that only weight json files are in the folder and not others.

    0

    likes

  • David O
    0

    likes

    Everything works but Craig B. you are trying to run the script from an old PowerShell 5.1 and not the latest 7... just run the new power shell and it will work...

    for us Europeans Fitbit exported for me weight in LBS and FAT in % so to convert it to KG i replaced this two lines:

    # Weight = $_.weight
    Weight = $_.weight * 0.453592

    # FatMass = if($_.fat -le 1) {""} else {[Math]::Round(($_.weight * ($_.fat / 100)),2)}
    FatMass = if($_.fat -le 1) {""} else {[Math]::Round(($_.weight * ($_.fat / 100) * 0.453592),2)}

    weight line converts from lbs to kg
    Fat converts from % to kg

    0

    likes

Leave a comment as