+ Reply to Thread
Results 1 to 2 of 2

Normalizing data of group membership from a csv for importing into Neo4j

Hybrid View

  1. #1
    Registered User
    Join Date
    11-07-2014
    Location
    Maryland
    MS-Off Ver
    2010
    Posts
    2

    Normalizing data of group membership from a csv for importing into Neo4j

    I have an application that exports data as plain text. Through a quick character replace in notepad++ I am able to get the data into csv and it looks like this in excel.

    excel1.PNG

    The Neo4j (which I am very new at) cypher query I am using to import the data needs to data to look like this.

    excel2.PNG

    The actual data can have dozens of columns and thousands of rows. Is there a quick way to do this in excel?

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,704

    Re: Normalizing data of group membership from a csv for importing into Neo4j

    this should work for you

    Option Explicit
    
    Sub Normalize()
        Dim s1 As Worksheet, s2 As Worksheet
        Dim i As Long, lr As Long, lrt As Long
        Dim lc As Long
        Set s1 = Sheets("Sheet1")
        Set s2 = Sheets("Sheet2")
        lr = s1.Range("A" & Rows.Count).End(xlUp).Row
        Application.ScreenUpdating = False
    
        For i = 1 To lr
            lrt = s2.Range("B" & Rows.Count).End(xlUp).Row + 1
            lc = s1.Cells(i, Columns.Count).End(xlToLeft).Column
            s1.Range("A" & i).Copy s2.Range("A" & lrt)
            s1.Range(Cells(i, 2), Cells(i, lc)).Copy
            s2.Range("B" & lrt).PasteSpecial xlPasteValues, , , True
            Application.CutCopyMode = False
        Next i
    
        lrt = s2.Range("B" & Rows.Count).End(xlUp).Row
        For i = 3 To lrt
            If s2.Range("A" & i) = "" Then
                s2.Range("A" & i) = s2.Range("A" & i - 1)
            End If
        Next i
    
        Application.ScreenUpdating = True
    
    End Sub
    How to install your new code
    1. Copy the Excel VBA code
    2. Select the workbook in which you want to store the Excel VBA code
    3. Press Alt+F11 to open the Visual Basic Editor
    4. Choose Insert > Module
    5. Edit > Paste the macro into the module that appeared
    6. Close the VBEditor
    7. Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)

    To run the Excel VBA code:
    1. Press Alt-F8 to open the macro list
    2. Select a macro in the list
    3. Click the Run button
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Help with normalizing data
    By Spyderwoman in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-22-2016, 11:29 AM
  2. [SOLVED] Normalizing The Data
    By zanshin777 in forum Excel Charting & Pivots
    Replies: 7
    Last Post: 09-15-2015, 07:47 AM
  3. [SOLVED] Count based on group membership
    By Cunner in forum Excel Formulas & Functions
    Replies: 18
    Last Post: 05-20-2014, 05:02 AM
  4. Normalizing data
    By jviola in forum Excel General
    Replies: 5
    Last Post: 06-07-2013, 10:05 AM
  5. AD User Group membership Macro
    By Vincent.Eymard in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-14-2010, 11:05 PM
  6. Group membership
    By jamex in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 03-09-2006, 09:10 AM
  7. normalizing data
    By 4gokycats in forum Excel General
    Replies: 2
    Last Post: 03-26-2005, 11:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1