logo elektroda
logo elektroda
X
logo elektroda

excel - How to add certain values to each line at the beginning ...

zadiar 21525 17
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 12709995
    zadiar
    Level 9  
    I have a csv file to import to the store and it should have an ID number, but you have to add it. I open an Excel file and I can add these numbers at the beginning of each line, but it's not about doing it manually, right?
    what command, etc. to use to make excel add "1 |" to the beginning of each line ?
    It's simple for stutterers, I don't know anything about it :P please help.
  • ADVERTISEMENT
  • #2 12710183
    Maciej Gonet
    VBA, Excel specialist
    Good morning,
    Please attach a sample file: what is it and how it should look after the modification, because the description is very imprecise - it is not known what the data structure is, should it be added at the beginning to each row in column A, should there be an additional column? You are writing about a csv file. Should it be exported to csv later or should it stay in Excel?
  • #3 12710232
    zadiar
    Level 9  
    excel - How to add certain values to each line at the beginning ...
    something like this ... the file is then to be saved as csv but there is no problem with that.
    The column is only A. In each line, the beginning and the end of the whole line of text is in column A. I think it helped.
  • #4 12710533
    Maciej Gonet
    VBA, Excel specialist
    There are several ways you can use it here. I will give 2 variants without the use of macros. If the problem occurs frequently, you can also use a macro.
    My proposition:
    1) Select the second column (col.B) in the height of the data.
    2) Enter the formula: = "1 |" & A1 into the cell in the first row (B1)
    3) While holding down Ctrl, press Enter.
    Option 1:
    4) We copy the column by Ctrl + C
    5) Home / Paste / Paste values.
    6) Place the cursor in column A and delete the column: Home / Delete / Delete sheet columns.
    7) We save the file in a convenient format, e.g. csv.
    Option 2:
    4) Save the file in .csv format and close it.
    5) Open the saved file again and delete the column A as in p.6, variant 1.
    6) We save the file in a convenient format, e.g. csv.

    The description applies to versions of Excel 2007 and later. In 2003, there is a slightly different path to referrals, but everything can also be done.
    If you need a macro, please write it down.
  • #5 12710612
    PRL
    Level 41  
    If you don't want to get tired of clicking, then:

    Code: text
    Log in, to see the code


    I don't understand why all items should have the same identifier. ;)

    I corrected ...
    Helpful post? Buy me a coffee.
  • #6 12710618
    zadiar
    Level 9  
    it doesn't work ... it doesn't change these numbers incrementally, but it only changes there is a one everywhere and I need 1 | and in the second line 2 | and in the third 3 |.
    writing will be easy for this csv etc. only this command causes a problem here.
  • ADVERTISEMENT
  • Helpful post
    #7 12710742
    Maciej Gonet
    VBA, Excel specialist
    If the numbering is to change, the formula can be e.g.
    = ROW (A1) & "|" & A1
    where A1 is the address of the first cell. But the Lord did not write that the number should change.
  • #8 12710986
    zadiar
    Level 9  
    Brother ... homie, friend ... I am not any Lord .. thank you very much for your help .. if you help me, you are a brother for me, not some kind ... you want me to call you, but this forum is probably for grooms more, what not?
    BTW ... It works !!
  • #9 12715344
    zadiar
    Level 9  
    One more question ... I don't get it because it should look like this:
    | "there is something written between the quotation marks as you can see" |

    and the first column does not have quotation marks, i.e. it is like this:
    | here something written between just the lines as you can see |

    excel - How to add certain values to each line at the beginning ...
    therefore, is it possible to delete everything that is written to the first "|" that is, everything that is written up to a certain character? we start deleting on the left and the deletion ends with the | character ? is it possible? damn, I won't delete 2,000 entries manually :P or else I don't add quotation marks to it, it would make no sense
  • ADVERTISEMENT
  • #10 12716547
    Maciej Gonet
    VBA, Excel specialist
    Buddy, as if you wrote more precisely what you mean!
    Does this sign "|" at the beginning should it remain or is it to be deleted?
    If it does, you can use a formula (assuming the original text is in A1):
    = FRAGMENT.TEXT (A1, FIND ("|", A1), LEN (A1))
    If it is to be deleted, one must be added:
    = FRAGMENT.TEXT (A1, FIND ("|", A1) +1, LEN (A1))

    Regards!
  • #11 12716629
    zadiar
    Level 9  
    ok that's like this:
    it looks raw like this:
    YSZUFPRN | "YSZUFPRN" | "Hygiene and Cleanliness >> Scoops" | "PRESTIGE Scoop.
    YWORMOC60L | "YWORMOC60L" | "Hygiene and cleanliness >> Garbage bags" | "Garbage bags.


    and it should look like this example:
    1 | "YSZUFPRN" | "YSZUFPRN" | "Hygiene and cleanliness >> Scoops" | "PRESTIGE scoop.
    2 | "YWORMOC60L" | "YWORMOC60L" | "Hygiene and cleanliness >> Garbage bags" | "Garbage bags.
  • #13 12716743
    Maciej Gonet
    VBA, Excel specialist
    I'm starting to get impatient now, buddy, decide what you want.
    In the latter version, the formula could be:
    = ROW (A1) & "|" "" & LEFT (A1; FIND ("|"; A1) -1) & "" "" & FRAGMENT.TEXT (A1; FIND ("|"; A1); LEN (A1) )
    The rest of the procedure as before.
    Or use the help of a colleague who proposes to do it in VBA.
    Regards.
  • #14 12716983
    zadiar
    Level 9  
    hey, brother, I found out in developer ... but I have error 28
    "out of stack space"
  • #16 12720247
    zadiar
    Level 9  
    it's me back ... I have another question ... it would be possible to remove some columns (because I remind you of everything in one line)?
    34 | "Plastic gloves B: BRALATEX-BLUE N" | "RALATEX-BLUES" | "Hand protection" | "Rubber and plastic gloves" | "Latex" | "http://home.pl/bhp/get .aspx? img = 0003441088.jpg "|" 0003441104.jpg "|" 0003441120.jpg "|" 0003441136.jpg "|" 23 "|" REIS "|

    to remove these jpg? so as to remove these as if the 7th, 8th and 9th column | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 etc. and to the value in the 10th add "http://home.pl/bhp /get.aspx?img= "just before the value" 0003441136.jpg "?

    So the example should look like this:
    34 | "Plastic gloves B: BRALATEX-BLUE N" | "RALATEX-BLUES" | "Hand protection" | "Rubber and plastic gloves" | "Latex" | "http://home.pl/bhp/get .aspx? img = 0003441136.jpg "|" 23 "|" REIS "| ?
    can you do that? I honestly don't see me correcting these thousands of lines like this pls help bros.
  • #17 12720613
    PRL
    Level 41  
    After executing the macro 'Id', execute this macro:

    Code: text
    Log in, to see the code


    You are changing the input, so I am not able to write you one macro that will produce the expected output from the input ...
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #18 12723501
    zadiar
    Level 9  
    ehhh, these questions were stupid, because it's best to use a program specially prepared for csv editing. there are a few free ones and they are cool! Thank you for your help

Topic summary

The discussion revolves around how to prepend an ID number to each line in a CSV file using Excel. The user initially seeks a method to add "1 |" to the beginning of each line without manual input. Various solutions are proposed, including using Excel formulas and VBA macros. A formula such as =ROW(A1) & "|" & A1 is suggested to achieve incremental numbering. Additionally, users discuss the need to format the output correctly and remove unnecessary data from the CSV. Ultimately, the user acknowledges the complexity and considers using specialized CSV editing software for better efficiency.
Summary generated by the language model.
ADVERTISEMENT