First time question here..
I have 100's of CSV files I need to convert using whatever means you think necessary.
The format is an ever-accumulating value e.g.
01/01/2012,96,1000,1100,1150,1200,1400,1450,......
02/01/2012,96,1900,2050,2060,......
But I need this in a single value format, so I need the difference between each value e.g.
01/01/2012,96,100,50,50,200,50......
02/01/2012,96,150,10,......
96 is the no. of values in each row.
Thats the 1st part, the next is to ignore any row which doesn't have 96 values,
so:
01/01/2012,1024,96,96.7,96.5,96.3,.....
would be ignored.
I'm very new to writing scripts/macros so baby steps please!
UNTESTED. I suggest:
Import a .csv to Excel.
Turn on Macro recorder.
Text to Columns with , as delimiter.
Filter column containing 96 to select any value other than 96 and delete those rows.
Add a row for the differences.
Concatenate the results of 96 columns with the likes of =A2&","&B2&","….
Adjust code to suit.
Related
I have an Excel file that contains hundreds of rows and columns of delimited data. Every cell looks like these two sample cells, and it used alphas and symbols to represent a specific result:
2-0*0*8-15-8-T4-<2-D4-C4-$4-6-4->2-X4-^6-%-|0|-/P4
4-0*0*3-13-5-K3-<2-S3-C3-$3-11-7-999-M3-^1-+-|4|-/W3
Each piece of the data within the delimited structure refers to a testing result and each test is contained on a single row, ranging from about 50 to 600 cells.
My challenge is I need to come up with a way to get an average of the numeric values contained in the 16th delimited segment, the number contained within the pipes, for example "|0|" and "|4|" in the two examples above.
I have been using formulas such as this to count all the cells in a row that have both "S" and "/W" in the cell:
=COUNTIF('Test Data'!2:2,"*S*/W*")
But I cannot figure out how to get the average of the numbers contained within the pipes "|4|" etc.
Any help is greatly appreciated.
As #Max pointed out, TEXTSPLIT seems to be the best solution to your problem.
If you have to avoid TEXTSPLIT, here is an alternative:
=AVERAGE(IFERROR(VALUE(MID(data,SEARCH("|",data,1)+1,SEARCH("|",data,SEARCH("|",data,1)+1)-SEARCH("|",data,1)-1)),""))
which can be slightly shortened to
=AVERAGE(IFERROR(VALUE(LET(a,SEARCH("|",data,1),MID(data,a+1,SEARCH("|",data,a+1)-a-1))),""))
where 'data' is the array of rows and columns containing the test codes.
I want to give a two-column Excel file as input to my script. But I need a two-column Excel file to have one feature: the second column must have 10 characters. Because the number of rows in the Excel file is large, I can not manually edit every cell in the second column.
So I need to put a control function in Excel to check the second column, so that it counts the number of characters in each cell in the second column and adds zero to the right of it, which is less than ten characters.
Based on my search, I realized that I could use the definition of the condition and the Len function, but the output was not what I wanted.
Full ID Expected Result
15 0000000015
159 0000000159
16 0000000016
43 0000000043
4329 0000004329
What I had tried :
=Right(A2,LEN(A2)+8)
but it was wrong.
How can I get my expected results in like the top example?
One way is to use Rept to repeat the correct number of zeroes:
=REPT("0",10-LEN(A2))&A2
Or simpler to use Text:
=TEXT(A2,"0000000000")
The nearest to your original formula would be something like
=LEFT("0000000000",10-LEN(A2))&A2
Or better the formula suggested by #JvdV
=RIGHT("0000000000"&A2,10)
To be honest I wasn't sure if by simply formatting the data as "0000000000" the zeroes would be preserved if (for example) you wrote the sheet out as a CSV, but I have tested it just to make sure and in fact they are so I think this remains the optimal solution.
Test Sheet
Resulting CSV
I have this formula on google sheet
VLOOKUP(upper(J2:J),colorState!A:B,{2}*sign(row(J2:J)),FALSE)
and I want it to sort the result ascending automatically when I add new data or edit(like arrayformula)
Is there anyway or any formula to do that? (I know that there's SORT formula but I'm not sure how to use it together)
thanks.
I believe I understand what you need :)
Essentially what I understand is that you would like to recreate the "main" sheet but have it automatically ordered by the 'color' column when new data is added. I don't have any idea how to do this to the raw data but you can mirror the raw data by creating another sheet (name 'mainmirror') and in cell A1 just enter this formula:
=query(main!$A:$R,"select * order by P ASC",-1)
It will take you 2 seconds to reformat with a filter view, and you'll be left with a mirror of 'main' that is always sorted by column P and should remain current as data is added.
Hopefully this is an acceptable workaround. Other option would be to use a script but this is less tedious if it's suitable.
Side note: this method will turn your values into strings to mirror them on the duplicate sheet, so on the 'main' sheet I would recommend changing the cell format of column P to a custom number format, 00, which will ensure there's a leading 0 if there's only one digit. this will cause the strings in the mirror to sort correctly, instead of 1,11,12,2,3,4,etc. If you're expecting column P to have 3 digit value, make the number format 000 accordingly.
So I have a csv file of around 15,000 rows. I only need to edit one of the 10 columns which is a Postcode. None of the columns have headers. It is currently in the format 'AB101AA' which I need to change to 'AB10 1AA'.
First off, is there a method for which I can do this for every row?
Then it gets more complicated in that Postcodes vary in format to these four types;
'A1 1AA',
'A10 1AA',
'AB1 1AA' and
'AB10 1AA'.
What I'm trying to do is to find a way to run through every row and first of all test the format to check whether it is as above and then edit if needs be, to force that space.
Any help would be much appreciated.
Cheers.
How about opening it in Excel, then
Use a formula to add a column which takes the first LENGTH(A1)-3 characters, a space, and the last three characters (copy/paste, or drag the + on the lower right corner of the cell, to make sure the formula is replicated in every row of that new column)
Copy the extra column
Paste the values over the original column
Delete the extra column
I have an excel document with about 500 rows.
I need to format all the cells in , let's say, B column from date to text.
This is how it looks like now:
2012-06-15
2012-06-01
2012-06-14
What it looks like when formated to text:
41075
41061
41074
It has come to my understanding that this is a timestamp representing days since 1st januari 1900, right? Anyhow, this is not what I want. I want the value of the field to be exactly what it is but with the column type of text. I've found various solutions for this using functions like this: =TEXT(B1, "yyyy-mm-dd") but that is not reformating the cell, it is extracting a value from one cell, reformat it and represent is as text in another.
The rule I'm after: I want all cells in B column to have the type text without changing the value
Thanks!
If you have a situation where columns A to D are dates of 500 rows you then:
Use the =TEXT(A1, "yyyy-mm-dd") function you describe in cell E1.
Copy this formula 4 columns wide, and 500 rows down.
Then copy and paste values to the preceding cells.
Copy Example:
Output:
You're right, Excel stores dates internally as number of days since January 1st, 1900 (apart from a minor leap year bug).
Thus, I'm afraid you cannot have both:
Either you keep the value e.g. (41075) and simply format it as a date, so it'll be displayed as 2012-06-15 -
Or you convert it to text format - but then you either
Lose the underlying value - if you convert it to the format you wish with a text function as you mentioned
Keep the value (41075), but cannot see the date
If you are typing in the values you can by adding a ' before the values to keep it as text.
e.g.
But depending on the method the third party service uses to import these values this may not work and I bet you will not get around it unless you export it to a text editor and import it again.
Also try to play with diferent types of text for your third party service, e.g. "2012-06-15" as some see the quotes and remove them.