Excel writing Problem: find correct row, write to empty cell
이전 댓글 표시
Hello Community,
I have a fairly advanced excel writing task. I have 2 types filenames that I need to write to specific cells in a spreadsheet. I acquire these names from user selection in a GUI. The files are named in this fashion: Label_SLR_LL_S1_0006_v1
Segment_SCH_RL_S3_0008_v1
So the files with "Label" are written to the Label and column and so forth.
First problem is I need to write to the next empty row instead of overwriting existing data. Ideally, I would like to check to see if the data already exist in the column, if it does, overwrite, if not find empty cell and write.
The second problem is the sheet contains data that is organized by row in this fashion:
2009-10-06 09-26-15_SHC_RL_S1_0002FinalData.mat
2009-10-06 09-28-01_SHC_RL_S2_0002FinalData.mat
2009-10-06 09-37-31_SHC_LL_S1_0002FinalData.mat
2009-10-06 09-39-18_SHC_LL_S2_0002FinalData.mat
2009-10-06 09-48-43_RHA_RL_S2_0002FinalData.mat
2009-10-06 09-50-06_RHA_RL_S3_0002FinalData.mat
2009-10-06 10-09-46_SLR_RL_S1_0002FinalData.mat
So the keywords are
SLR_LL_S1
SHC_LL_S2
RHA_RL_S3
and so forth Each row in the the sheet contains data specific to that identifer. I need to be able to write my filenames:
Label_SLR_LL_S1_0006_v1
Segment_SCH_RL_S3_0008_v1
into the correct row based on the keywords.
The second part of my problem might not be necessary if a simple sort in excel can put my filenames in the correct order? I dont think it can because of how they are named.
I realize this a hefty question and any suggestion are greatly appreciated. I litteraly spent over 3 hours searching the Answers and newsgroup but couldt find a solution to this problem.
댓글 수: 5
Fangjun Jiang
2011년 8월 2일
Please double check your question.
SCH_RL or SHC_RL?
What are all the keyworkds? The three provided don't cover all the examples.
B_Richardson
2011년 8월 2일
B_Richardson
2011년 8월 2일
Fangjun Jiang
2011년 8월 3일
So, to summarize, you have nx3 strings in an Excel file, you want to insert new strings into the right cell. The right cell means that the strings with the same keywords are grouped together. I assume you want to insert at least 3 strings at a time, with one for each of the "Header", "Label" and "Segment" column. These 3 strings shall have the same keywords.
B_Richardson
2011년 8월 3일
채택된 답변
추가 답변 (1개)
Fangjun Jiang
2011년 8월 3일
1 개 추천
You can't expect an exact code to solve your problem with so much details.
댓글 수: 7
B_Richardson
2011년 8월 3일
B_Richardson
2011년 8월 3일
Fangjun Jiang
2011년 8월 3일
In that case, it is import to ask for a particular question, using simple example, not with overwhelming task details. It is true that sometimes the answers provided are hard to understand. Maybe people want to show off their skills with those one-line or no-loop code. What you can do is to ask for further explanation, or the best way is to try it out in MATLAB, step by step.
B_Richardson
2011년 8월 3일
Fangjun Jiang
2011년 8월 4일
Not less details but enough or sufficient details. For example, if you want to ask how to extract the keyword 'SHC_RL_S1' from the file name '2009-10-06 09-26-15_SHC_RL_S1_0002FinalData.mat', you may just need to state this and provide maybe a few examples of the file names. Next, you may ask how to match this keyword to a list of existing keyword. Once you got answers to all this individual, specific questions, you'll able to stitch them together and solve your problem. You may have a huge, complicated task, you need to do divide-and-conquer.
B_Richardson
2011년 8월 4일
Fangjun Jiang
2011년 8월 4일
Doug Hull provided lots of tutorial video over there, you can watch them whenever you like. Not every line can be put in a break point. You don't need to actually. Have a few break point and then you can press F10 to run line by line.
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!